4

Is this correct?

SharedPreferences are stored in databases?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nilesh Verma
  • 914
  • 1
  • 11
  • 26
  • may be its off topic but [this](http://stackoverflow.com/questions/3572780/android-sharedpreference) might help you. – Harry Joy Feb 04 '11 at 08:53
  • @Harry Joy it is not off-topic, he/she is having confusion regarding the storage place of sharedpreferences. – Paresh Mayani Feb 04 '11 at 09:15
  • @Paresh: may be possible its not off topic but i am not sure if he finds his answer on that site thats why written like that. – Harry Joy Feb 04 '11 at 09:19

3 Answers3

3

No it is not correct. SharedPreferences are stored as XML files in your applications directory.

Octavian Helm
  • 39,405
  • 19
  • 98
  • 102
1

I am agreed with @Octavian answer (up voted), it is stored inside the file.

SharedPreferrences are stored in databases?

As i have written answer, NO, its stores inside the file inside your project directory.

To view this file, go to DDMS Perspective, click on the File Explorer. From File Explorer, data -> data -> your project -> shared_prefs.

Above, shared_prefs is the folder contains all the shared preferences you have declared and used.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
-2

Actually shared preferences store value into a variable .it is saved as like key-value pair

below is the code is used for store and retrieve values through shared preference values.

SharedPreferences prefs=getSharedPreferences("Key", 0);
          Editor e=  prefs.edit();
           e.putString("Name", "AAA");
           e.commit();

For retrieve the shared prefs value use below code

SharedPreferences prefs=getSharedPreferences("Key", 0);
          String s= prefs.getString("Name", "");
Pinki
  • 21,723
  • 16
  • 55
  • 88
  • 1
    The question was how are the preferences stored on disk, not how you read/write them. – Felix Feb 04 '11 at 09:44