title: Saving Instance to avoid losing data switching between tab
body: <p>My app has two tabs and switching between the tabs, makes me lose anything I enter in <strong>Current Trip</strong> So I modified my code to save the state.</p>
  
  <p><img src="https://i.stack.imgur.com/IVjjP.png" alt="enter image description here"></p>
  
  <pre><code>package com.test.testing;
  
  
  public class Trip2 extends Fragment {
       EditText nameOfInf;    
      @Override
      public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState ) {
  
          if ((savedInstanceState != null) &amp;&amp; (savedInstanceState.getString("nameof") != null)) {
              Toast.makeText(getActivity(), savedInstanceState.getString("nameof"),2000).show();
          }
          else {
              Toast.makeText(getActivity(), "DIDNT SAVE",2000).show();
          }
          final RelativeLayout mFrame2 =  (RelativeLayout) inflater.inflate( R.layout.trip, container, false ); 
  
          final Button btnCalc = (Button) mFrame2.findViewById(R.id.btnCalculate);
  
          nameOfInf = (EditText) mFrame2.findViewById(R.id.etName);
          final EditText tollAmount = (EditText) mFrame2.findViewById(R.id.etToll);
  
          btnCalc.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  //DO SOMETHING
              }
          });
          return mFrame2;
      }
  @Override
  public void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      outState.putString("nameof", nameOfInf.toString());
  }
  }
  </code></pre>
  
  <p>It always displays </p>
  
  <blockquote>
    <p>DIDN't SAVE</p>
  </blockquote>
  
  <p>How do I fix the issue?</p>