Search code examples
androidandroid-layoutandroid-activitylifecycle

How can I save the state of an activity in Android


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.


Solution

  • 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.