-2

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?

Jeroen Boot
  • 47
  • 1
  • 8

1 Answers1

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