Reputation: 19
I've implemented saving (onSaveInstanceState) & restoring (onCreate) through Bundle. It works when activity is recreated due to the change of orientation but it doesn't work when activity is recreated after the other apps claimed resources. In this case it turns out that my data keys in bundle are absent. Why? I am at a loss.
Upvotes: 1
Views: 255
Reputation: 14472
The Bundle saved in onSaveInstanceState()
and passed back in through onCreate()
is not persistent and is only designed for saving state during configuration changes and Activity recreation during the lifetime of your app.
If your app is destroyed, as appears to be happening here, you will need to store your values somewhere persistent, for example in SharedPreferences
Use onPause()
and onResume()
to save and restore.
Upvotes: 1