0

is there a way to save values through various starts of an app? I need to save some statistics (records of a game). In objective-c I used UserDefaults, what's it in Java? If possible I'd like to take a simple way (one line of code).

Philip
  • 1,068
  • 3
  • 12
  • 21
  • 1
    possible solutions http://stackoverflow.com/questions/785973/what-is-the-most-appropriate-way-to-store-user-settings-in-android-application?lq=1 – StarsSky Mar 16 '14 at 18:37

1 Answers1

1

one line of code

No, that's not going to happen. But if you just have simple data and not much of it then you can use SharedPreferences

There is a good, basic example of using SharedPreferences here in the docs

But if you are going to be storing a lot of data for a game then you probably want to implement an SQLite DB

See Storage Options for what will work best for you.

codeMagic
  • 44,549
  • 13
  • 77
  • 93
  • Thanks! I'm going to use a DB for the heavy data. Just for a simple int-value the SharedPreferences will work. – Philip Mar 16 '14 at 18:53