Reputation: 1707
I'm trying to understand life cycle methods and onSaveInstanceState().
Is it correct that I actually only need to worry about onCreate() where I set up whatever my activity requires, and onPause() where I should save a copy of any of my own data into persistent storage to be restored later in onCreate()?
Can/Should I just ignore onSaveInstanceState()? I notice that some samples add data into the bundle, but if one is hardening data to persistante storage elsewhere why would I want to do this too?
Ian
Upvotes: 2
Views: 2070
Reputation: 4908
onSaveInstanceState() is used to store state when the activity goes to onStop() and use onRetrieveInstanceState() or onCreate() to get previous state.
But if the app is killed in background then you can't maintain state. At those scenarios Shared Preferences will be better than this.
Upvotes: 1