BINGO!

If you're using getDefaultSharedPreferences, you want to use
getApplication() to get the context to supply.

The shared preference file name can differ if you use differing
contexts. You want to use the same context every time, no matter which
activity or service you look at it from. So you need the Application.

Using adb (you may need a rooted phone or the emulator to do this),
look at /data/data/<pkgid>/shared_prefs, which is where the preference
files get created as .xml files.

This will give you a much better understanding of how this works, and
will also let you more directly debug any problems.

On Mar 15, 5:51 pm, "Matt (preinvent)" <m...@preinvent.com> wrote:
> One thing has just occurred to me.  My app contains a service, an
> activity and a widget.  Depending on what gets updated first, the
> database connection is instantiated using a Context from one of these.
>
> If it's instantiated with the Context from say the service, then at
> another point it's instantiated with the Context from the activity,
> will this cause me any problems?

-- 
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

Reply via email to