Changes

Saving and Restoring the State of an Android Activity

29 bytes added, 15:19, 10 January 2019
Saving the State
For the purposes of this example, and having disabled the automatic saving of text for the EditText view, we need to make sure that the text entered into the EditText field by the user is saved into the Bundle object and subsequently restored. This will serve as a demonstration of how to manually save and restore state within an Android application and will be achieved using the putCharSequence() and getCharSequence() methods of the Bundle class respectively.
== Saving Saving the State ==
The first step in extending the StateChange application is to make sure that the text entered by the user is extracted from the EditText component within the onSaveInstanceState() method of the StateChangeActivity activity, and then saved as a key-value pair into the Bundle object.
[[Image:as3.0_statechange_component_tree.png]]