Can I save my database updates in onSaveInstanceState() of activity life cycle ?
Yes, you can save, but make sure that it will not take too much of time.
Yes, we can save database of any size in that function.
No, because that function might not be called all the time.
none of the above.
We have to save all DB updates on or before onPause() function of activity life cycle. Because this is the last guaranteed function to be called on all scenarios of an activity life cycle.
Note : If you save DB in onSaveInstanceState, then that function will not be called if user presses back button on the activity.
So it will end up in loosing all the database un saved data.
Back To Top