private TextView mTextView; private static final String KEY_TEXT_VALUE = "textValue"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTextView = (TextView) findViewById(R.id.main); if (savedInstanceState != null) { CharSequence savedText = savedInstanceState.getCharSequence(KEY_TEXT_VALUE); mTextView.setText(savedText); } } @Override protected void onSaveInstanceState (Bundle outState) { super.onSaveInstanceState(outState); outState.putCharSequence(KEY_TEXT_VALUE, mTextView.getText()); }
References
https://stackoverflow.com/questions/13022677/save-state-of-activity-when-orientation-changes-android