-2

I have a problem saving my application's data state. I want to open the last close state of my application when the continue button is clicked. Meaning when the user plays a game and leaves the game on any stage, the next time they open the game will start where they left off, when the continue button is clicked. Please give me any idea and suggestions to solve the issue. Wait for your kind reply. Thanks in advance.

Sbonelo
  • 664
  • 1
  • 9
  • 25

1 Answers1

0

You can use SharedPreferences to save the state of different variables and objects.

Convert your object into JSON format and store as a string in shared preferences.

If you want to save the state when activity is paused and restore when activity is resumed, see how to make an object parcelable here

Community
  • 1
  • 1
Randev
  • 36
  • 3
  • still i couldn't do my work. please help me to solve my problem. i have 10 levels in my android application.if the user play game and left on 6th level, i want to store 6th level on save button which is held on main activity page please help me how can i do this. – Pink Pretty Mar 03 '15 at 06:45
  • You can't just save a "level", but instead save the fields and properties that compose the level. Can you post your code here so that we can have an idea? – Randev Mar 03 '15 at 07:36
  • my code is too long which is not placing here. i am using 2 arrays type of image view 3 text view containing scores time and hint. i just want to open that level where the user left it. my application is a game.i want when user click on save button from main activity page then open the last close activity by clicking save button. how can i link it for all levels??????? – Pink Pretty Mar 03 '15 at 07:50