0

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

user1314147
  • 174
  • 1
  • 5
  • 25

1 Answers1

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