title: How to remove only one fragment from backstack in fragment navigation component?
body: <p>In my app i have used one activity and four fragment . In this app I used navigation component. 
  My fragment loading sequence is  A->B->C->D</p>
  
  <p>In fragment D On device back button press I want to remove fragment C from backstack so that fragment B can open.
  Any one suggest me how can I do 
  Thank you in advance</p>
  
  <p>this is my navigation_graph.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;navigation xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/navigation_graph"
  
      app:startDestination="@id/firstFragment"
      &gt;
      &lt;fragment
          android:id="@+id/firstFragment"
          android:name="com.education.javaprogramming.fragments.MainFragment"
          android:label="fragment_first"
          tools:layout="@layout/activity_main" &gt;
  
          &lt;action
              android:id="@+id/action_firstFragment_to_displayList1Fragment"
              app:destination="@id/displayList1Fragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
              /&gt;
          &lt;action
              android:id="@+id/action_firstFragment_to_displayList2Fragment"
              app:destination="@id/displayList2Fragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
              /&gt;
          &lt;action
              android:id="@+id/action_firstFragment_to_helpFragment"
              app:destination="@id/helpFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
              /&gt;
          &lt;action
              android:id="@+id/action_firstFragment_to_quizzFragment"
              app:destination="@id/quizzFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
              /&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/displayList1Fragment"
          android:name="com.education.javaprogramming.fragments.DisplayList1Fragment"
          android:label="fragment_display_list1"
          tools:layout="@layout/fragment_display_list1"
  
          &gt;
          &lt;argument
              android:name="position1"
              app:argType="integer" /&gt;
          &lt;action
              android:id="@+id/action_displayList1Fragment_to_firstFragment"
              app:destination="@id/firstFragment" /&gt;
          &lt;argument
              android:name="name"
              app:argType="string" /&gt;
          &lt;action
              android:id="@+id/action_displayList1Fragment_to_displayList2Fragment"
              app:destination="@id/displayList2Fragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
  
              /&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/displayList2Fragment"
          android:name="com.education.javaprogramming.fragments.DisplayList2Fragment"
          android:label="fragment_display_list2"
          tools:layout="@layout/fragment_display_list2" &gt;
          &lt;action
              android:id="@+id/action_displayList2Fragment_to_displayList1Fragment"
              app:destination="@id/displayList1Fragment"
  
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
              /&gt;
          &lt;action
              android:id="@+id/action_displayList2Fragment_to_firstFragment"
              app:destination="@id/firstFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
              /&gt;
          &lt;argument
              android:name="position1"
              app:argType="integer" /&gt;
          &lt;argument
              android:name="position2"
              app:argType="integer" /&gt;
          &lt;argument
              android:name="name"
              app:argType="string" /&gt;
          &lt;action
              android:id="@+id/action_displayList2Fragment_to_displayListInDeFragment"
              app:destination="@id/displayListInDeFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
              /&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/displayListInDeFragment"
          android:name="com.education.javaprogramming.fragments.DisplayListInDeFragment"
          android:label="fragment_display_list_in_de"
          tools:layout="@layout/fragment_display_list_in_de" &gt;
          &lt;action
              android:id="@+id/action_displayListInDeFragment_to_displayList2Fragment"
              app:destination="@id/displayList2Fragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
              /&gt;
          &lt;argument
              android:name="position1"
              app:argType="integer" /&gt;
          &lt;argument
              android:name="position2"
              app:argType="integer" /&gt;
          &lt;argument
              android:name="position3"
              app:argType="integer" /&gt;
          &lt;argument
              android:name="name"
              app:argType="string" /&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/helpFragment"
          android:name="com.education.javaprogramming.fragments.HelpFragment"
          android:label="fragment_help"
          tools:layout="@layout/fragment_help" &gt;
          &lt;action
              android:id="@+id/action_helpFragment_to_firstFragment"
              app:destination="@id/firstFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
              /&gt;
          &lt;argument
              android:name="position1"
              app:argType="integer" /&gt;
          &lt;argument
              android:name="name"
              app:argType="string" /&gt;
          &lt;action
              android:id="@+id/action_helpFragment_to_aboutFragment"
              app:destination="@id/aboutFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
              /&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/aboutFragment"
          android:name="com.education.javaprogramming.fragments.AboutFragment"
          android:label="fragment_about"
          tools:layout="@layout/fragment_about" &gt;
          &lt;action
              android:id="@+id/action_aboutFragment_to_helpFragment"
              app:destination="@id/helpFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
              /&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/quizzFragment"
          android:name="com.education.javaprogramming.fragments.QuizzFragment"
          android:label="fragment_quizz"
          tools:layout="@layout/fragment_quizz" &gt;
          &lt;action
              android:id="@+id/action_quizzFragment_to_firstFragment"
              app:destination="@id/firstFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
              /&gt;
          &lt;action
              android:id="@+id/action_quizzFragment_to_displayExamFragment"
              app:destination="@id/displayExamFragment" /&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/displayExamFragment"
          android:name="com.education.javaprogramming.fragments.DisplayExamFragment"
          android:label="fragment_display_exam"
          tools:layout="@layout/fragment_display_exam" &gt;
          &lt;action
              android:id="@+id/action_displayExamFragment_to_quizzFragment"
              app:destination="@id/quizzFragment"
              app:enterAnim="@anim/enter"
              app:exitAnim="@anim/exit"
              app:popEnterAnim="@anim/pop_enter"
              app:popExitAnim="@anim/pop_exit"
  
              /&gt;
          &lt;argument
              android:name="position1"
              app:argType="integer" /&gt;
          &lt;action
              android:id="@+id/action_displayExamFragment_to_resultFragment"
              app:destination="@id/resultFragment" /&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/resultFragment"
          android:name="com.education.javaprogramming.fragments.ResultFragment"
          android:label="fragment_result"
          tools:layout="@layout/fragment_result" &gt;
          &lt;action
  
              android:id="@+id/action_resultFragment_to_quizzFragment"
              app:destination="@id/quizzFragment" /&gt;
          &lt;argument android:name="givenAnswers"
              app:argType="reference"
              /&gt;
          &lt;argument android:name="actualAnswers"
              app:argType="reference"
              /&gt;
      &lt;/fragment&gt;
  
  
  &lt;/navigation&gt;
  </code></pre>