0

How to save instance state and use saved instance state in android?

I have created an app, in which there are two text views and two buttons. Clicking on first button displays a city from array of four city and clicking on second button displays language of city in first textview. But when i rotate the screen, values inside the textviews get lost. I know that onSaveInstance state() will. help me to overcome this issues but i don't know how to use it. can any one help me??? Hope someone will. Thanks alot in advance.

2nd Jun 2017, 5:29 PM
Swapnil Janrao
Swapnil Janrao - avatar
1 Réponse
0
Override onSaveinstance and put the two string values of textviews into the outstate bundle. Then in onCreate or onRestoreinstance get the strings from the bundle and set them back.
7th Jun 2017, 1:36 AM
Philip Newby
Philip Newby - avatar