Friday, January 18, 2013

Re: [android-developers] Re: Application.onCreate Method Randomly Called?

On Fri, Jan 18, 2013 at 10:11 AM, Jake Colman <colman@ppllc.com> wrote:
> Am I making a fundamental mistake in how this is supposed to be done?

No, that all seems OK.

> You've already told me that when the application is recreated it gets a
> new context. If so, how are preferences persisted across recreations of
> my application if the "key" to those preferences are the context?

The "key" to those preferences is the package name. An easy way to get
the package name is by calling getPackageName() on a Context. The
"key" to those preferences is not the Context itself.

In this case, the "key" is used as the basis of a filename, for the
XML file which contains the persisted SharedPreferences.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Aqui estão alguns sites onde você pode perguntar ou responder dúvidas
sobre desenvolvimento de aplicações para Android:
http://www.andglobe.com

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment