Why isn't my onSaveInstanceState saving my EditText Value properly when going from landscape back to portrait
<p>So I have seen multiple examples of this done and for some reason I cannot get onSaveInstanceState to save the value of my EditText properly.</p>

<p>I have a very simple example that looks just like the image below.</p>

<p><a href="https://i.stack.imgur.com/Bc48A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bc48A.png" alt="enter image description here"></a></p>

<p>first a <strong>TextView</strong>, then an <strong>EditText</strong> followed by a <strong>Button</strong>.</p>

<p>When clicking the Button it saves the value in EditText and then applies it to the TextView.</p>

<p>So the problem is it only works once, meaning I start in Portrait mode then turn my phone to Landscape and it saves then back to Portrait and it does not so the TextView appears blank.</p>

<p>My Example code is below:</p>

<p><strong>activity_main.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="50dp"
    android:paddingLeft="50dp"
    android:paddingRight="50dp"
    android:paddingTop="50dp"
    tools:context="mydomain.com.savetest.MainActivity"&gt;

    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Default Text"
        android:textSize="48sp"
        android:id="@+id/textView"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"/&gt;

    &lt;EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/editText"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:hint="choose a word"/&gt;

    &lt;Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="SAVE WORD"
        android:id="@+id/bu"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"/&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p><strong>MainActivity.java</strong></p>

<pre><code>package mydomain.com.savetest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private TextView mTextView;
    private EditText mEditText;
    private Button mButton;
    private String editTextValue;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTextView = (TextView) findViewById(R.id.textView);
        mEditText = (EditText) findViewById(R.id.editText);
        mButton = (Button) findViewById(R.id.button);

        editTextValue = mEditText.getText().toString();
        mTextView.setText(editTextValue);

        if(savedInstanceState != null){
            mTextView.setText( savedInstanceState.getString("text") ); //setting the saved value to the TextView
        }


        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                editTextValue = mEditText.getText().toString();
                mTextView.setText(editTextValue);
            }
        });
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);

        outState.putString("text", editTextValue); //saving EditText value
    }
}
</code></pre>

<p>So the whole goal of this is to get the TextView to save the word that was int the EditText and maintain it switching from portrait to landscape. As of now if I type lets say "Car" it will update the TextView with "Car" and will also have the value of Car even turning to Landscape mode, BUT when turning back to portrait the TextView value is gone and has nothing. I Cant seem to figure out whats going on here because I have set the value of EditText to TextView in the beginning on onCreate() so when the app starts again it should take the saved value just fine.</p>