title: Android : Save fragment state and restore the view values
body: <p>Hi iam trying to save the state of the fragment when one fragment is replaced with other fragment. 
  Consider in my Activity i have a <strong>fragmentA</strong> with <strong>textview-1</strong> and <strong>textview-2</strong>. when i click on the textview-1 i am <strong>replacing fragmentA with fragmentB</strong> which has a list view.
  Now when i click on the fragmentB list item iam getting the list value and updating the textview-1. same thing iam doing for textview-2 but when i return back, the textview-1 value is gone. How to save the state of the fragment A and its textview-1 value.</p>
  
  <p>Tried as below</p>
  
  <pre><code>@Override
  public void onSaveInstanceState(Bundle outState) {
      // TODO Auto-generated method stub
      super.onSaveInstanceState(outState);
       outState.putString("curChoice", strtext);
  }
  </code></pre>
  
  <p>and in OnActivityCreated()</p>
  
  <pre><code> if (savedInstanceState != null) {
               // Restore last state for checked position.
               strtext = savedInstanceState.getString("curChoice", "");
               //incrementdata(strtext);
           }
  </code></pre>
  
  <p>But always the <strong>savedInstanceState</strong> is giving null.</p>