I am working on an App in android studio. The only thing is that if you close the app you need to start over with the game. Do you guys know how i can integrate a autosave option in my app that every time the user closes the app and start it up again that they don't need to start over?
Asked
Active
Viewed 57 times
-2
-
1Do u know Android Lifecycle ?Do u heard about **savedInstateState** ?. i think you need to look into it. – ULHAS PATIL Jan 22 '16 at 13:24
-
have you read about the onClose()/onDestroy() event? You should take a look at that... maybe that's what you need! – ParkerHalo Jan 22 '16 at 13:25
-
I am kinda new to Android development. But thanks for the answer! @ULHASPATIL – Jeroen Boot Jan 22 '16 at 13:25
-
you are welcome, look into it, you will find out lots of answers regarding that. just google it. – ULHAS PATIL Jan 22 '16 at 13:26
-
Possible duplicate of [Saving Activity state on Android](http://stackoverflow.com/questions/151777/saving-activity-state-on-android) – ByteWelder Jan 22 '16 at 14:15
1 Answers
1
onSavedInstanceState is used when recreating an activity due to things like orientation changes. check this link: http://developer.android.com/training/basics/activity-lifecycle/recreating.html
If the user is exiting the application completely then you should look into persisting the data with a sqlite db or using shared preferences during the activity lifecycle, check this link: http://www.herongyang.com/Android/Android-Application-Activity-Lifecycle.jpg
When the user starts the app again then check the persisted data during onCreate()

Gareth Price
- 128
- 10