title: Android FragmentTransaction.addToBackStack confusion
body: <p>I was studying Fragments and got little confused on differentiating <code>FragmentTransaction.replace(id, fragment, tag)</code> and <code>FragmentTransaction.addToBackStack(tag)</code> calls. Lets say that my current fragment is <strong>FragmentA</strong> and then I loaded <strong>FragmentB</strong>. I want that in future, when I need to load <strong>FragmentA</strong>, I don't have to reload it. Just load the old one in old state. I used the following code segment:</p>
  
  <pre><code>public void loadFragment(Fragment fragmentB, String tag) {
      FragmentManager fm = getSupportFragmentManager();
      View fragmentContainer = findViewById(R.id.fragment_container);
  
      FragmentTransaction ft = fm.beginTransaction();
      ft.replace(fragmentContainer.getId(), fragmentB, tag);
  
      ft.addToBackStack(tag);
  
      ft.commit();
  }
  </code></pre>
  
  <p>Now I am confused, where should I add the string tag? In <code>replace()</code> or in <code>addToBackStack()</code> or in both calls? Can you explain the difference between these two tag places?</p>