I want to save the sate of an activity even if it is destroyed, Means if i have a lot of controls on the activity view then when ever changes occur on the controls after activity is called like selected any options on the spinner or the TextView text is changed etc I can save each control state separately but I want to save the whole activity object type thing so if activity recreated then all the options on the controls are selected at once. So that there is less coding. and If I perform any animation on any control then its changed position are saved if any animation is applied on that control.
Asked
Active
Viewed 60 times
0
-
1http://stackoverflow.com/questions/151777/saving-activity-state-in-android?rq=1 – Vny Kumar Nov 12 '14 at 06:23
-
I have known about Shared preferences but the problem is that .f have a large number of controls then it is to hard save all the states of controls at once. and the code will be too lengthy. – Furqan Ali Nov 12 '14 at 07:36
-
Um, no it isn't. It's just monkey work. Maybe, if you have so many controls, you need to rethink your design. – David Wasser Nov 12 '14 at 22:01
2 Answers
1
Just use Shared Preferences. Its that simple.
Refer : http://developer.android.com/reference/android/content/SharedPreferences.html

vkm
- 548
- 7
- 23
-
I have known about Shared preferences but the problem is that .f have a large number of controls then it is to hard save all the states of controls at once. and the code will be too lengthy. – Furqan Ali Nov 12 '14 at 07:35
0
I have used Shared preferences with Gson and saved the whole object as string at once. IT is not I wanted but It helped to save the state in ore less way. Thanks for all to reply.

Furqan Ali
- 137
- 2
- 13