title: Android Fragment Back Stack
body: <p>I have used multiple Fragments in my Project. I want to save a Fragment's state and restore this state when I come back to this. In this Fragment I show multiple images which change on button click. I use the following code for this: </p>
  
  <pre><code>String backStateName = fragment.getClass().getName();
  FragmentManager fragmentManager = getSupportFragmentManager();
  boolean fragmentPopped = fragmentManager.popBackStackImmediate(backStateName, 0);
  if (!fragmentPopped) {
   FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
   fragmentTransaction.replace(R.id.container_body, fragment);
   fragmentTransaction.addToBackStack(backStateName);
   fragmentTransaction.commit();
  }
  </code></pre>
  
  <p>It works fine &amp; it saves state, but it does not show previous image's.  </p>
  
  <p>Any help, suggestion or tutorials would be highly appreciated. Thank you.</p>