title: How to keep information when I change layout android studio
body: <p>Let's assume that my Android app has an activity_main.xml and a second_layout.xml.
  In each of them there is a button and an editText.</p>
  <p>The buttons allows me to change layout.
  Any time I switch from a layout to another, the content of the ediTexts is deleted.
  Can anyone tell me how to keep it?</p>
  <p>I tried using the methods <code>onSaveInstanceState(Bundle outState)</code>  and <code>onRestoreInstanceState(Bundle outState)</code>  but it doesn't work.</p>
  <p>Here's part of my code:</p>
  <pre><code>    editTextSingleLW = (EditText) findViewById(R.id.editTextSingleLW);
      String single_LW;
  
      @Override
      public void onSaveInstanceState(Bundle outState) {
          outState.putString(&quot;Single_LW&quot;,singleLW);
  
          super.onSaveInstanceState(outState);
      }
  
      @Override
      public void onRestoreInstanceState(Bundle outState){
          super.onRestoreInstanceState(outState);
  
          editTextSingleLW.setText(outState.getString(&quot;Single_LW&quot;)+&quot;&quot;);
      } 
  </code></pre>
  <p>Any idea?</p>
  <p>Thank You very much.</p>