tags:

views:

159

answers:

1

Hi,

I have some things in my app that I need to store, in order to have it available the next time I open the application. I wonder if I could save them using the sharedPreferences mechanism even if I don't have any "view" associated with them ! .If this is possible please let me know, if not, what would you suggest instead ?

+1  A: 

All you need is a component that can furnish you a handle to the android.os.Context An Activity is such a component. SharedPreference's data is stored in a file - somewhat akin to a properties file (key,value pair).

You can also create your own files and store it in the app's private directory.

Jacques René Mesrine
could you show here through a piece of code how to store an int for example ?
rantravee
http://pastebin.com/qXY1c3fp
Jacques René Mesrine
Thanks a bunch !
rantravee