3.) Activity persistent state is managed with the method getPreferences(int) inside the onPause() and onResume() lifecycle methods.
4.) Run the application.
Steps to Create:
1.) Open Eclipse. Use the New Project Wizard and select Android Project. Give the respective project name i.e. StatePersistence. Enter following information:
Project name: StatePersistence
Build Target: Google APIs
Application name: StatePersistence
Package name: com.sample.StatePersistence
Create Activity: StatePersistence
On Clicking Finish StatePersistence code structure is generated with the necessary Android Packages being imported along with StatePersistence.java. StatePersistence class will look like following: