For Android applications, there are two lightweight techniques for saving simple data-shared preference and a pair of Event Handlers used to save the details of the activity instance. Both mechanisms use the name/value (NVP) mechanism to store simple basic types of values.
With shared preference, you can create a name table for the key/value pair in your application, which can be shared among components running in the same context.
Shared preference supports the following data types: Boolean, String, float, long, and integer. It is the best way to quickly store default values, class instance variables, current UI status, and user settings. Most of them are used for data storage between user sessions and sharing settings between program components.
In another optional way, activity provides onsaveinstancestate processing functions. It is designed to save the UI status of the activity that becomes the terminated object when resources are running in short supply.
The working mechanism of processing functions is similar to the shared preference mechanism. It provides a bundle parameter that represents the basic type of the key/value table and can be used to save the value of the activity instance. This bundle will be passed into the oncreate and onrestoreinstancestate methods in the form of parameters later.
The bundle of the UI state is used to record the value of the activity required to render the same UI after unexpected restart.