-2

I'm extremely new to Android development - how do I save data? Is it possible to systematically save data (e.g. strings, ints, just values in general) or do I have to save all this manually?

  • Can you elaborate more? – Phantômaxx May 11 '14 at 16:18
  • How is it possible I can just save my data? I have some values (strings/ints) - how can I save the variables to be accessed when the user opens the app again after they've closed it? – user3623069 May 11 '14 at 16:19
  • save it across multiple app sessions ? – Shivam Verma May 11 '14 at 16:19
  • You can use the SharedPreferences: http://developer.android.com/reference/android/content/SharedPreferences.html – Phantômaxx May 11 '14 at 16:20
  • That's not example appropriate - I just want to save data in general. When the user closes the app, how would I access data previously used in the last session? – user3623069 May 11 '14 at 16:22
  • 1
    You know, there's a site called [google](https://google.com) out there. [Saving Data](http://developer.android.com/training/basics/data-storage/index.html) and [Storage Options](http://developer.android.com/guide/topics/data/data-storage.html) are the first two results. – Tobias May 11 '14 at 16:23
  • As I said, it's the perfect case for the SharedPreferences... You not only can save key-value pairs, but you can also read them back, when you restart your app! Incredible, uh? – Phantômaxx May 11 '14 at 16:39
  • possible duplicate of [How to use SharedPreferences](http://stackoverflow.com/questions/3851560/how-to-use-sharedpreferences) – Howli May 11 '14 at 16:46

1 Answers1

0

use the SharedPreferences API, it's perfect for saving primitive values. they are stored in a xml file in the format of key-value.

Israel Tabadi
  • 574
  • 4
  • 11