title: How to update layout after onConfigurationChange?
body: <p>I am building my first app and am almost done. (yay!) Now all I have to do is to set up the Java for the onConfigurationChange used when the orientation is changed as well as the keyboard is pulled out.
  First off, the problem is that when the orientation changes everything gets erased because a new new layout is put in place by the setContentView method. This of course makes sense, however I was wondering if there was any way or possible workaround that I can have the edittext and textview values stay constant when the orientation/keyboard is changed. I have tried various things, such as taking the string values before the setContentView, however I found that this would only result in a NullPointerException.</p>
  
  <p>Basically I'm trying to keep the edittext and textview values the samne as the orientation or whatever changes.</p>
  
  <p>Here is a brief summary of my code for a reference</p>
  
  <p>This is NOT the actual code, just a summary pf what I'm doing.</p>
  
  <pre><code>    public class MainActivity extends Activity {
  
        protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
       //do some stuff that is the core of the app. Nothing that would impact this question though
  
      }
  
        public void onConfigurationChanged(Configuration newConfig) {
       super.onConfigurationChanged(newConfig);
  
       if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
  
          setContentView(R.layout.landscape);
              // same code that was within the onCreate. Just doing stuff related to  my  app 
  
      }if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
  
          setContentView(R.layout.main);
              // same code that was within the onCreate. Just doing stuff related to  my  app
      }
           }
      ' }
  </code></pre>
  
  <p>And yes, I did write in my AndroidManifest file the
  android:configChanges="orientation|keyboardHidden"
  The app works like it should, I just don't have the text viwes and edittexts being updated.
  Thanks!</p>