Question

When i click home button and then come back to to my application it doesn't show the last values on the listview or any other view it just look same with when i started the application.I believe it is can be done with onResume and onPause but i couldn't find how .

Was it helpful?

Solution

Multiple ways to do this:

  1. An SQLite database
  2. Store the data as a file on the SD card.
  3. SharedPreferences for the activity.
  4. As a static variable in the Application class.

Switching between Android activities

Had asked the same question some time back.

OTHER TIPS

You can store all values in SharedPreferences in onPause, and then load them again in onResume and populate your views using that data.

To get a full understanding, read about activity lifecycles and saving activity state here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top