title: Delete one specific fragment from the Android backstack
body: <p>For a android tablet application I use 2 fragments. One on the left side on the screen and one on the right side. When you click on a button at the right fragment, another fragment wil be added on the top of the right fragment. This fragment is added to the backstack. </p>
  
  <pre><code>FragmentTransaction ft = getFragmentManager().beginTransaction(); 
  ft.add(R.id.fragmentlayout, fragment2);
  ft.addToBackStack("Fragment2");
  ft.commit();
  </code></pre>
  
  <p>The backstack is now:</p>
  
  <p>[fragment 1] -> [fragment 2]</p>
  
  <p>On the left side is also a button that opens a fragment on top of the left fragment (same as fragment2) and adds it to the backstack. The backstack is now</p>
  
  <p>[fragment 1] -> [fragment 2] -> [fragment 3]</p>
  
  <p>On fragment 2 is a button to close that fragment. </p>
  
  <pre><code>getFragmentManager().popBackStack("Fragment2", FragmentManager.POP_BACK_STACK_INCLUSIVE);
  </code></pre>
  
  <p>The problem is when I only want to close [fragment 2], [fragment 3] will also be destroyed. I can remove the fragment manualy by calling</p>
  
  <pre><code>FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
  ft.remove(fragment2).commit();
  </code></pre>
  
  <p>But the backstack will remain</p>
  
  <p>[fragment 1] -> [(ghost) fragment 2] -> [fragment 3]</p>
  
  <p>So you need to press back one time more to close the application.</p>
  
  <p>Is there a way to only remove [fragment 2] from the backstack and leave [fragment 3] on the screen?</p>