gt: 					Data dataIterator = this.data.get(i);
context: package com.example.savedisplay;
  
  import java.util.ArrayList;
  
  import android.annotation.TargetApi;
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.os.Build;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.CheckBox;
  import android.widget.ListView;
  import android.widget.Toast;
  
  @TargetApi(Build.VERSION_CODES.HONEYCOMB) public class MainActivity extends Activity
  {
  	ArrayList<Data> data = null; //Data displayed on the ListView
  	MyCustomAdapter dataAdapter = null;
  	final String SEPARATOR = "~"; //The line separator used when writing in a file
  	final int REQ_CODE_EDIT = 1;
  	final String KEY_IDENTIFIER = "editedData";
  	final String RESULT = "result";
  
  	@Override
  	public void onCreate(Bundle savedInstanceState) 
  	{
  		super.onCreate(savedInstanceState);
  		setContentView(R.layout.activity_main);
  
  		Log.d("ATag", "On create");
  	}
  	
  	@Override
  	public void onResume()
  	{
  		super.onResume();
  		Utils.activityContext = MainActivity.this;
  		displayListView();
  		invalidateOptionsMenu();
  	}
  	
  	public boolean onCreateOptionsMenu(Menu menu)
  	{
  		MenuInflater inflater = getMenuInflater();
  	    inflater.inflate(R.menu.main, menu);
  	    
  		int noOfCellsChecked = 0;
  		
  		for(int i = 0; i < data.size(); i++)
  		{
  			Data dataIterator = data.get(i);
  			if(dataIterator.isSelected())
  			{
  				++noOfCellsChecked;
  			}
  		}
  		
  		Log.d("SomeTag", "Recreating the action bar||" + String.valueOf(noOfCellsChecked));
  		
  	    if (noOfCellsChecked == 0)
  		{
  	    	menu.getItem(1).setEnabled(false);
  		    menu.getItem(2).setEnabled(false);
  		}
  	    else
  	    if(noOfCellsChecked >= 2)
  	    {
  	    	menu.getItem(1).setEnabled(false);
  	    }
  		
  		return true;
  	}
  	
  	public boolean onOptionsItemSelected(MenuItem item)
  	{
  		switch(item.getItemId())
  		{
  			case R.id.action_new:
  			{
  				Intent intentToCreate = new Intent(this, EditActivity.class);
  				startActivity(intentToCreate);
  				
  				break;
  			}
  			case R.id.action_edit:
  			{
  				String dataToEdit = null;
  				int indexOfEdited = -1;
  				for(int i = 0; i < data.size(); i++)
  				{
  					Data dataIterator = data.get(i);
  					if(dataIterator.isSelected())
  					{
  						indexOfEdited = i;
  						dataToEdit = dataIterator.getName();
  					}
  				}
  				
  				String[] dataAndIndex = {dataToEdit, String.valueOf(indexOfEdited)};
  				
  				if (dataToEdit != null)
  				{
  					Intent intentToEdit = new Intent(this, EditActivity.class);
  					intentToEdit.putExtra(KEY_IDENTIFIER, dataAndIndex);
  					startActivityForResult(intentToEdit, REQ_CODE_EDIT);
  				}
  				else
  				{
  					Toast.makeText(this, "Data could not be edited.", Toast.LENGTH_SHORT);
  				}
  				
  				break;
  			}
  			case R.id.action_discard:
  			{
  				DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener()
  				{
  				    @SuppressWarnings("unchecked")
  					@Override
  				    public void onClick(DialogInterface dialog, int which) 
  				    {
  				        switch (which)
  				        {
  				        	case DialogInterface.BUTTON_POSITIVE:
  				        	{
  				        		Utils.deleteFile();
  				        		for(int i = 0; i < data.size(); i++)
  				        		{
  				        			Data dataIterator = data.get(i);
  				        			if(dataIterator.isSelected())
  				        			{						
  				        				data.remove(i);
  				        				--i;
  				        			}
  				        			else
  				        			{
  				        				String encrypted = "";
  				        				try 
  				        				{
  				        					encrypted = Utils.encrypt(Utils.SEED, dataIterator.getName());
  				        				} 
  				        				catch (Exception e) 
  				        				{
  											// TODO Auto-generated catch block
  											e.printStackTrace();
  										}
  				        				Utils.writeToFile(encrypted + SEPARATOR, Context.MODE_APPEND);
  				        			}
  				        		}			
  				        		dataAdapter.dataArray = ((ArrayList<Data>)data.clone());
  				        		dataAdapter.refreshAdapter();				        	
  
  				        		break;
  				        	}
  
  				        	case DialogInterface.BUTTON_NEGATIVE:
  				        		//No button clicked
  				        		break;
  				        }
  				    }
  				};
  
  				AlertDialog.Builder builder = new AlertDialog.Builder(this);
  				builder.setMessage("Are you sure you want to delete the selected items?").setPositiveButton("Yes", dialogClickListener)
  				    .setNegativeButton("No", dialogClickListener).show();
  								
  				break;
  			}
  			default:
  				break;
  		}
  		
  		return true;
  	}
  	
  	protected void onActivityResult(int requestCode, int resultCode, Intent data)
  	{
  		super.onActivityResult(requestCode, resultCode, data);
  		
  		if (data != null)
  		{
  			if (requestCode == REQ_CODE_EDIT)
  			{
  				String[] result = data.getStringArrayExtra(RESULT);
  				Log.d("ON_ACTIVITY_RESULT", "The edited text is: " + result[0] + " and the index is: " + result[1]);
  				Data editedData = new Data(result[0], false);
  				this.data.set(Integer.parseInt(result[1]), editedData);
  
  				Utils.deleteFile();
  				for(int i = 0; i < this.data.size(); i++)
  				{
  