0

I am currently developing an app that keeps track of how many time you do something. I want the data to be saved so that when the app is closed and reopened, the same data will come back to be added onto. The data is for the user's long term use so the app will close eventually, but I need the data (2 counters) to be saved.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hunter
  • 37
  • 1
  • 6
  • 1
    possible duplicate of [How can I save data from android service?](http://stackoverflow.com/questions/6564591/how-can-i-save-data-from-android-service). Also [How to save data in an android app](http://stackoverflow.com/questions/10962344/how-to-save-data-in-an-android-app). – Michael Petrotta Dec 27 '13 at 23:47

2 Answers2

2

You can use SharedPreferences to save the counters and can edit it every time the user reopen the Application.

Please read the following:

Use of SharedPreferences

How to use SharedPreference

Continuing integer counter from sharedpreferences

Community
  • 1
  • 1
Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39
1

There are 3 ways of storing data in android:

In your case I would suggest using SharedPreferences, because it is recommended for all key-value settings in android apps.

pawegio
  • 1,722
  • 3
  • 17
  • 29