Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PreferenceManager.setDefaultValues readAgain parameter and new preferences

I'm using PreferenceManager.setDefaultValues(context,R.xml.preferences,false) to set the default values of the preferences in my application and I've noticed that if I add a new preference then my PreferenceFragment does not show a default value for it, even if it is set in the preferences.xml..

Is this due to the fact that I specify readAgain as false?

I know I can simply try-and-see, but I just wanted to be sure that the readAgain is meant for this purpose, i.e. re-read the default values not to re-set user settings but to set the new properties' default values. If this is exactly the purpose of the readAgain flag, then can you give me a reason not to always set readAgain to true, given that it does not reset user preferences?

like image 994
Gianni Costanzi Avatar asked May 14 '12 06:05

Gianni Costanzi


1 Answers

Setting the readagain flag to true will ensure that all unset-default values are set again. That's the summary.

Setting the readagain will cause extra overhead since basically it means that, the code will go through the entire SharedPreference once more to check them. With the readAgain false,all it does is to check whether the file ( has_set_default_values.xml ) which is used as a marker for setting default values is present or not.

In any case, It won't set any values that are already set .

like image 169
NT_ Avatar answered Sep 28 '22 03:09

NT_