1

I am loading values in one activity, and then process it and show the result in new activity. I do not want to retain the first activity when second activity is created but need some data in an object from first activity in results screen.

I read that the data created in first activity gets destroyed when exiting it. How to get the data in second activity ?

I am not looking at simple passing using Intents. But getting data of first activity in new activity after first activity is finished.

Ananda
  • 11
  • 2

2 Answers2

0

The best way to use frequently accessible data between activities are:-

  1. pass the data via intent in a bundle
  2. Save it in shared preferences
  3. Save it in a database
  4. Save the data to a file
  5. save the data on the webserver
Atish Agrawal
  • 2,857
  • 1
  • 23
  • 38
0

Is the data a class in and of itself? If so, make that class implement Parcelable and set it as the bundle to an intent to start your new activity. That way Android handles the lifecycle of your first Activity and you get the data safely to the new activity.

If these are application settings, try using Shared Preferences.

If you need persistent data handling across multiple activities, use a Database (SQLite).

Robin Eisenberg
  • 1,836
  • 18
  • 26
  • The data is stored in a class with list of strings and this class contains another class with list of strings. If I send as parcelable.. Will the new activity create a copy with list of strings.. Some where I read that after first activity finishes data created in first activity will not be available. – Ananda Feb 25 '14 at 17:40