I have a preferences.xml file that I use to set up preferences that will be used throughout our application. Right now, I just have the preferences.xml file setup to how we want it, I was wondering for each preference that we want to store, do we need to use code to actually save the preference so it can be retrieved later, or does it automatically save it? Thanks
Asked
Active
Viewed 143 times
1 Answers
0
If your preferences.xml
file will be changes/updated, you will need to write the code so that the changes are saved in the preferences. For example, if I have to update the "score" every time in the xml, I would use a code like the one below:
SharedPreferences sp = getSharedPreferences("preferences",Context.MODE_PRIVATE);
Editor ed =sp.edit();
ed.putInt("score", 1000);
ed.commit();

Akhil
- 13,888
- 7
- 35
- 39
-
What if these are just preferences that will only be changed a couple of times max? – user1314147 Apr 10 '12 at 20:01
-
if they are changed at all, you would need to use the above standard code to save those changes. – Akhil Apr 10 '12 at 20:07