title: How to save state in fragment
body: <p>I have 4 button to replace fragment in activity [fragment A , fragment B , fragment C , fragment D] and then I replace fragment A to activity and I change value in fragment A after that I replace fragment B to fragment A and replace fragment C to fragment B . But I want to replace fragment A to fragment C . How to save state in fragment A.</p>
  <p>Code when I commit fragment</p>
  <pre><code>  private void beginFragmentTransaction(BaseFragment fragment) {
      String tag = fragment.getClass().getName();
      currentFragmentTag = tag;
  
      boolean fragmentPopped = getChildFragmentManager().popBackStackImmediate(tag, 0);
  
      if (!fragmentPopped) {
          getChildFragmentManager().beginTransaction()
                  .replace(R.id.container, fragment, tag)
                  .addToBackStack(tag)
                  .commit();
      }
  
  }
  </code></pre>
  <p>Diagram to replace</p>
  <blockquote>
  <p>fragment A -------&gt; fragment B</p>
  <p>fragment B -------&gt; fragment C</p>
  <p>fragment C -------&gt; fragment A</p>
  </blockquote>
  <p>PS. I don't want to use back button to back to fragment A , I want to replace fragment A and restore data in the first commit.</p>