0

Here is my code. I try to start SharedPreferences but it seems that context is wrong - why?

Context context;
SharedPreferences SPgroup = context.getSharedPreferences(SPF_FILE_G, Context.MODE_PRIVATE);
Chad White
  • 309
  • 1
  • 4
  • 15
  • possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – Rick S Apr 02 '15 at 21:15
  • I've tried "SharedPreferences SPgroup = context.getApplicationContext().getSharedPreferences(SPF_FILE_G, Context.MODE_PRIVATE);" but didn't work anyway – Chad White Apr 02 '15 at 21:17
  • let me get it straight: are you calling a method on a not-instantiated variable? – injecteer Apr 02 '15 at 22:12
  • 1
    Did you check if context is not null? – Exceen Apr 02 '15 at 22:26
  • In the code of the post, the variable `context` is not initialized. – Stephan Apr 03 '15 at 07:20

0 Answers0