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.Kiril Kirilov– Kiril Kirilov2010-12-29 14:45:10 +00:00Commented 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 directlyBytecode– Bytecode2010-12-30 07:38:35 +00:00Commented Dec 30, 2010 at 7:38
Add a comment
|
2 Answers
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.
Comments
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.