简体   繁体   中英

Android: SharedPreferences file doesn't create

I created a SharedPreferences like this:

SharedPreferences sharedpreferences = getSharedPreferences("MyPREFERENCES", Context.MODE_PRIVATE);

And I created a file xml called MyPREFERENCES which I put in the folder values, but the sharedpreferences doesn't work. Of course I write only the part of the code which created problems. How can I create the MyPREFERENCESf file?

SharedPreferences are not not stored as an XML file... You can not access the file directly, (not of a way I know). These are stored on the storage and can be fetched by doing the same action that you specified. Basically: The SharedPreferences file (egMyPREFERENCES, as per your code) is automatically created in the storage the very first time it is called. You cannot access, edit or create this file directly

-Daniel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM