onSaveInstance() Not functioning how I want

Hello everyone I’m developing an android appliation, and I want text that is generated to be preserved even when the page is navigated away from. For example, I want to be on the page where the text is generated then click a button to go to a new page, then go back to the previous page and still see the generated text. This is the code I have so far for restoring and saving the value:

public class HighRiskActivity extends AppCompatActivity
{
    //This value is the one being generated and the value I want to be reserved
    TextView t;
    //...
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.high_risk);
            t = (TextView) findViewById(R.id.textID);

            Bundle extras = getIntent().getExtras();
            if(extras != null)
            {
                //Test key is set in another class
                String value = extras.getString(TEST_KEY);
                t.setText(value);
            }
        }
            @Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putString(TEST_KEY, t.getText().toString());

}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState)
{
    super.onRestoreInstanceState(savedInstanceState);
    String myString = savedInstanceState.getString(TEST_KEY);
}

Sorry for the code being indented weird hopefully it isn’t too much of an issue. The text is generated perfectly when I land on the activity, but when I hit a button and try to go back to the activity with the generated text it isn’t there anymore. Take into consideration that the generated text is blank before anything gets generated into it, the reason for this is based on a certain selection the text will get generated if that button isn’t pressed then nothing is generated.

Any help is appreciated!