You need to have some persistence for your data. If you only want it to be kept while currently in the app then you can use static
variables. Create a class that holds a static ArrayList
or something similar which you will add the data to after selecting an item from the list in the first Activity
. Then each time you go to the second Activity
you can populate your list using the data from that static ArrayList
.
Your other options are to store this data in SharedPreferences
(probably not ideal for this situation but maybe) or a DB
if you want it to persist if the application is closed.
Edit
For any of the options you can override onBackPressed()
@Override
public void onBackPressed()
{
// save data here if it hasn't yet been saved
super.onBackPressed();
}