title: Shared Preferences error
body: <p>I have an activity like :</p>
  
  <pre><code>public class LogoActivity extends Activity{
  
  SharedPreferences data = getSharedPreferences("la",MODE_PRIVATE);
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_logo);
      SharedPreferences.Editor editor = data.edit();
  
      for(int i=0;i&lt;5;i++){
          ImageAdapter.items[i] = data.getInt(Integer.toString(i),0);
      }
      name = Names.forDrawable(id);
      check.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
  
              a=name.isCorrect(text.getText().toString());
              if(a==true){ 
  
              ImageAdapter.items[LogoSelectionActivity.pos] = 1;
              Intent intent = new Intent(LogoActivity.this, CorrectActivity.class);
              intent.putExtra ("clicked_position", LogoSelectionActivity.pos);
              startActivity(intent);
  
              }
              else{
                  incorrect.setVisibility(0);
              }
  
          }
          });
  
      for(int i = 0;i&lt;5;i++){
          editor.putInt(Integer.toString(i),ImageAdapter.items[i]);
      }
      editor.commit();
  
      back.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              Intent intent = new Intent(LogoActivity.this, LogoSelectionActivity.class);
              startActivity(intent);  
              }
      });
  
  }
  }
  </code></pre>
  
  <p>I hold stages of 5 items in imageAdapter like 0 or 1. Default is all 0. I am changing this stage at my activity. After changing, i want to save this stage and get it when user opens the app again. I wrote the code but I have errors. I also tried to get preferences at the end of the code instead the beginning but nothing changed.</p>
  
  <p>Error message:</p>
  
  <pre><code>03-06 17:27:49.520: E/AndroidRuntime(14808): FATAL EXCEPTION: main
  03-06 17:27:49.520: E/AndroidRuntime(14808): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.turkishlogoquiz/com.example.turkishlogoquiz.LogoActivity}: java.lang.NullPointerException
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2024)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.app.ActivityThread.access$600(ActivityThread.java:140)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.os.Handler.dispatchMessage(Handler.java:99)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.os.Looper.loop(Looper.java:137)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.app.ActivityThread.main(ActivityThread.java:4898)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at java.lang.reflect.Method.invokeNative(Native Method)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at java.lang.reflect.Method.invoke(Method.java:511)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at dalvik.system.NativeStart.main(Native Method)
  03-06 17:27:49.520: E/AndroidRuntime(14808): Caused by: java.lang.NullPointerException
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:160)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at com.example.turkishlogoquiz.LogoActivity.&lt;init&gt;(LogoActivity.java:32)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at java.lang.Class.newInstanceImpl(Native Method)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at java.lang.Class.newInstance(Class.java:1319)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
  03-06 17:27:49.520: E/AndroidRuntime(14808):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2015)
  </code></pre>
  
  <p>Any help?</p>