Ok. Just one more thought on this: in-memory data isn't really persistent in any case, Android or not.
If the data in question is something that should persist - something the user enters and then expects to come back and view or edit - then it should be persisted in some way. This would also apply to an application having just one activity. -- Kostya 2011/4/12 Christophe <[email protected]> > hello Kostya, > > yes I think I going to use a lazy initialization, and retrieve the > data from the database if it's null. It's a bit more work but it > should works :) > > On Apr 12, 11:24 am, Kostya Vasilyev <[email protected]> wrote: > > Static variables aren't set to null. The process gets killed and > > reinitialized again when/if the user comes back. > > > > If you use a static to only pass data between activities, then don't > > reference it past that. Have the receiving activity store the data > somewhere > > more persistent: a database, a data file, shared prefs, or a save it > > onSaveInstanceState. > > > > If you want the static obejct to act as some sort of persistent data > manager > > that your activities can rely on, have it save the data somewhere, and > use > > lazy initialization to bring the data in from that persistent memory as > > needed. > > > > If the data size is small, you might indeed be better off passing it > between > > activities as part of the intent, as extras (basic types of Parcelable). > > > > -- Kostya > > > > 2011/4/12 Christophe <[email protected]> > > > > > > > > > > > > > > > > > that's probably the case. They should mention in the documentation > > > that static variable can be set to null at anytime, since they > > > explicitely state that static variable can be use to pass data between > > > activities ... (http://developer.android.com/resources/faq/ > > > framework.html#3) > > > > > What the best way to keep data then ? May be a singleton ? I'm afraid > > > the instance will be set to null too :( > > > > > On Apr 12, 10:04 am, appel <[email protected]> wrote: > > > > If you don't set them to null somewhere it is most likely because > your > > > > application process has been killed and restarted. > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to > [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

