문제

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 .

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top