It is perfectly fine to persist state in storage (via SharedPreferences, flat files, databases, etc). There are some things you will almost certainly want to store in onSaveInstanceState() (such as the current position in the list... well the framework does that for you already), and some things always go in persistent storage (such as the current preferences set by the user), and then a big gray area of things that you may handle one or the other way, depending on the behavior you want (either associated with that "instance" of the activity, or retained across launches).
On Thu, Apr 30, 2009 at 11:02 AM, Eric Hackborn EH <hackb...@gmail.com>wrote: > > I have a simple app that has three windows, each with a corresponding > activity. It's very common to switch back and forth between activities, > but of course state gets wiped out of the top-most activity when the > user has finished with it, and I want that state to persist. So I have > two questions: > > 1. Currently, I'm persisting the state by saving it to the MODE_PRIVATE > SharedPreferences in onStop(), then restoring it in onCreate(). > Is this acceptable, or is there a better way to handle it? > > 2. If it is acceptable, a side effect is that the state now persists > between app invocations. Personally I like this, but I haven't > seen any guidelines for Android on whether minor settings > should persist past the life of the app. Is this a good practice > for Android or not? > > thanks, > eric > > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---