title: Activity fails in onRestoreInstanceState() - Null Pointer Exception
body: <p>I have an ArrayList of an object. I am trying to save it as mentioned in the below code. When I try to fetch the object in onRestoreInstanceState() I m getting NullPointerException. Kindly point me where the code needs correction</p>
  
  <pre><code>  @Override
    protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState); 
      Log.i("MemoryGame", "onSaveInstanceState");   
      outState = new Bundle(); 
      outState.putSerializable("saveMemory", (Serializable) memory);
    } 
  
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
      super.onRestoreInstanceState(savedInstanceState);
      Log.i("MemoryGame", "onRestoreInstanceState");    
      ArrayList&lt;Memory&gt; retrievedMemory =  (ArrayList&lt;Memory&gt;) savedInstanceState.getSerializable("saveMemory"); 
      Log.i("MemoryGame", "onRestoreInstanceState : memory " + retrievedMemory.get(0).getPictureName()); 
    }
  </code></pre>
  
  <h2>Logcat</h2>
  
  <pre><code>03-29 16:26:58.047: E/AndroidRuntime(16281): FATAL EXCEPTION: main
  03-29 16:26:58.047: E/AndroidRuntime(16281): java.lang.RuntimeException: Unable to start activity ComponentInfo{kids.animals.fruits.objects.brain.puzzle.memory.game.free/kids.animals.fruits.objects.brain.puzzle.memory.game.free.MemoryGame}: java.lang.NullPointerException
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.app.ActivityThread.access$600(ActivityThread.java:138)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.os.Handler.dispatchMessage(Handler.java:99)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.os.Looper.loop(Looper.java:213)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.app.ActivityThread.main(ActivityThread.java:4787)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at java.lang.reflect.Method.invokeNative(Native Method)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at java.lang.reflect.Method.invoke(Method.java:511)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at dalvik.system.NativeStart.main(Native Method)
  03-29 16:26:58.047: E/AndroidRuntime(16281): Caused by: java.lang.NullPointerException
  03-29 16:26:58.047: E/AndroidRuntime(16281): at kids.animals.fruits.objects.brain.puzzle.memory.game.free.MemoryGame.onRestoreInstanceState(MemoryGame.java:2135)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.app.Activity.performRestoreInstanceState(Activity.java:900)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1130)
  03-29 16:26:58.047: E/AndroidRuntime(16281): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2049)
  03-29 16:26:58.047: E/AndroidRuntime(16281): ... 11 more
  </code></pre>