Life Cycle of Activity

To save Activity instance variable, Android offers two variataion of Shared Preference. The first uses a Shared Preference named specifacally for your Activity other relies on a series of lifecycle event handlers.

Saving Activity State

If you want to save Activity information that does not need to be shared with other components (e.g. class instance variables), you can Activity.getPreferences() without specifying a Shared Preferences name.

Saving and Resorting Activity

Activity offers the onSaveInstanceState handler to persist data associated with UI state across session.

If an Activity is closed by the user (by pressing the back button), or programmatically with a call to Finish, instance state bundle will not be passed in to onCreate or onRestoreInstanceState Activity is next created.

Overriding an Activity's onSaveInstanceState event handler, use its bundle parameter to save. UI instance vale . Store value using the same put method .

Activity complete its activity life cycle,but only when it's not being explicity finished with call to finish.