I have an activity which has an array list
ArrayList array = new ArrayList();
i want this array list to be pa
you can pass an intent to already running activity.. follow this http://www.helloandroid.com/tutorials/communicating-between-running-activities for that in the intent you can add an extra like this
Intent contactsIntent = new Intent(getApplicationContext(),
ContactCards.class);
contactsIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
appWidgetId);
//Bundle containing the serialized list
Bundle extraContacts = new Bundle();
//Putting the array list templist is the array list here
extraContacts.putSerializable("CONTACT_KEY", tempList);
extraContacts.putString("CALL_STRING", CALL_STRING);
contactsIntent.putExtras(extraContacts);
contactsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(contactsIntent);
You can declare you ArrayList as a static one like this,
public static ArrayList<String> array = new ArrayList<String>();
By doing this you can access your ArrayList from anywhere by
activity_name.array;
where activity_name is the activity or class in which you declare the static ArrayList
use 1st activity
Intent i=new Intent(ArraylistpassActivity.this,second.class);
i.putStringArrayListExtra("key",arl);startActivity(i);
2nd activity:
arl=bundle.getStringArrayList("key");
Based on the fact that you mention a 'Save' button, I think you would rather save this data to SharedPreferences or an SQLiteDatabase.
I am unsure of what it would mean to 'save' some data to another Activity
and not start it.
With your data in a persisted state, you should be able to access it from any one of your other Activity
's, which is what is sounds like you are after.