How to save an activity state using save instance state?

Posted by Pinki | Updated on

Want to save an activity state using save instance state? You need to override onSaveInstanceState(Bundle savedInstanceState) and write the application state values you want to change to the Bundle parameter like this:

The Bundle is essentially a way of storing a NVP (“Name-Value Pair”) map, and it will get passed in to onCreate() and also onRestoreInstanceState() where you would then extract the values from activity like this:

Reference:
https://stackoverflow.com/questions/151777/how-to-save-an-activity-state-using-save-instance-state?rq=1


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers