title: Android: Bundle always null
body: <p>I have a fragment and for screen rotation I want to save some states I have</p>
  
  <pre><code>@Override
  public void onSaveInstanceState(Bundle bundle)
  {
      super.onSaveInstanceState(bundle);
      bundle.putSerializable("myList", myList);
      bundle.putString("test", "test");
   }
  </code></pre>
  
  <p>to save the data I need, I can see in the debugger that the code is at least called and then to get the data I have</p>
  
  <pre><code>@Override
  public void onActivityCreated(Bundle savedInstanceState) 
  {
      super.onActivityCreated(savedInstanceState);
  
      if(savedInstanceState != null)
      {
          //do something        
      }
      else
      {
          //do something else
      }
  }
  </code></pre>
  
  <p>but here I always end up the else-brach of my if-statement. I have no idea why it is null. Thanks.</p>
  
  <p><strong>EDIT</strong>
  changed the code according to the first answer plus:</p>
  
  <p>When rotating the screen I see in the debuger this:</p>
  
  <blockquote>
    <ol>
    <li>onSaveInstanceState is called</li>
    <li>onCreate is called --> bundle != null</li>
    <li>onCreate is called again (Why?) --> bundle = null</li>
    <li>onCreateActivity is called --> bundle = null</li>
    </ol>
  </blockquote>
  
  <p><strong>EDIT 2</strong>
  I found simlar posts about tabs, where they got detached and that is why it is called twice. I have to admit I haven't fully understood these posts... but it could be related to that. In my Activity I have the following code</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      OverviewFragment of = new OverviewFragment();
      FragmentTransaction tof = getFragmentManager().beginTransaction();
  
      tof.replace(R.id.frag_overview, of);
      DetailFragmentInitial df = new DetailFragmentInitial();
      tof.replace(R.id.frag_details, df);
      tof.commit();
  
  }
  </code></pre>
  
  <p>and might have to change that somehow... but I am not sure... If I perform the fragment transaction only if the savedInstaceState is null then it seems to work. But I am not sure if I run into a different issue later. Someone some background knowledge on this?</p>