1

i am using application context for saving data, and it work fine for me ,but the problem comes,when i press home button and take some other application and return to my application after a long time my app fail, no data in application context, how can i save the application context

2
  • Besides the shared preferences mechanics other guys have recommended, I think that it is not bad to look at the developer.android.com/guide/topics/fundamentals.html, the part for application lifecycle, there is wonderful picture there. Commented Dec 29, 2010 at 14:45
  • i know sharedprefrance is good method but i have large data that contain custom object also,so using it difficult for me, so am looking for anyway to save the application context directly Commented Dec 30, 2010 at 7:38

2 Answers 2

2

This question should help you. You could store the application context in shared preferences. When resuming an activity, first test if application context is empty and if it is, then load data from shared preferences.

Sign up to request clarification or add additional context in comments.

Comments

2

This is only logical. Apps can be closed by the device on low memory.

Have a look here. I suggest shared preferences since it is easy and just works.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.