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?
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 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With