sasq wrote: > Am I right to assume that onSaveInstanceState() is not normally called > (which my logging indicates) - but only when the system is forced to > kill an Activity.
To quote the documentation: "...for those methods that are marked as being killable, after that method returns the process hosting the activity may killed by the system at any time without another line of its code being executed. Because of this, you should use the onPause() method to write any persistent data (such as user edits) to storage. In addition, the method onSaveInstanceState(Bundle) is called before placing the activity in such a background state, allowing you to save away any dynamic instance state in your activity into the given Bundle, to be later received in onCreate(Bundle) if the activity needs to be re-created... Note that it is important to save persistent data in onPause() instead of onSaveInstanceState(Bundle) because the later [sic] is not part of the lifecycle callbacks, so will not be called in every situation as described in its documentation." http://developer.android.com/reference/android/app/Activity.html > If so, since onPause() does not receive a bundle, what is the best way > to save state that should be restored the next time the Activity is > created ? A database. Or, in an ordinary file in the application's file storage area (e.g., openFileOutput()). Or, inside of some SharedPreferences. Or, in "the cloud" (i.e., store it out on the Internet somewhere, if you have connectivity). Or, if all you are worried about is screen rotations, use onRetainNonConfigurationInstance(). Or, if you don't need the state to be stored on-disk, have a local Service or custom Application object hold onto it. Which of these (and any others I didn't think of off the top of my head) is "best" is really up to you, based upon your application and its requirements. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, $35/Year --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---