Where exactly does the NullPointerException happen?

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Fri, Apr 9, 2010 at 9:52 AM, Stu <stuart.gilb...@gmail.com> wrote:

> Hi, I seem to be struggling with the concept of Context in Android
> when dealing with the application preferences.
>
> I have an application with a few different classes. I need to be able
> to get the value of one of the preferences from a class that is not my
> main class, but I can't seem to get it working at all.
>
> I get a NullPointerException with the following (as well as about a
> hundred other variations):
>
>    final SharedPreferences prefs =
> PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
>    final boolean increasing = prefs.getBoolean("preference_name",
> false);
>
> Am I doing something completely stupid? Is there some useful reading I
> can do on Context to see what I'm doing wrong? Is there an example app
> that anyone can think of that might be helpful? I've searched Google
> and Google Code a few times and I keep finding different things that
> are related, but not the same.
>
> I'm about ready to tear my hair out and cry myself to sleep at this
> point. :(
>
> I really appreciate any pointers.
>
> Regards,
> Stuart.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>
> To unsubscribe, reply using "remove me" as the subject.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to