开发者

Are SharedPreferences stored in databases?

开发者 https://www.devze.com 2023-02-09 01:44 出处:网络
Is this correct? SharedPreferences are stored in database开发者_Go百科s?No it is not correct. SharedPreferences are stored as XML files in your applications directory.I am agreed with @Octavian answe

Is this correct?

SharedPreferences are stored in database开发者_Go百科s?


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


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.


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", "");
0

精彩评论

暂无评论...
验证码 换一张
取 消