How to Save State of Activity in Android

Posted on .

This is very simple and asked everywhere like interviews and during our LIVE projects . Lets explore .

METHOD – 1

You need to @ override

and note down your application values which you want to save eg:

Bundle stores values in the form of (Name-Value-Pair) map . It is passed in onCreate() . The values can be extracted through onRestoreInstanceState() .

 

 METHOD – 2

Instead of saving data in

you can use methods like