i am having the same problem as this thread, default values are not being initialized for preferences,
i have 2 preference.xml files
this is the onCreate on my main activity:
protected void onCreate(Bundle savedInstanceState) {
PreferenceManager.setDefaultValues(this,R.xml.preference,false);
PreferenceManager.setDefaultValues(this,R.xml.other_preference,false);//this doesn't work now because of the previous row
String value = PreferenceManager.getDefaultSharedPreferences(this).getString("pref_from_other_preference", null); //this returns null
}
my problem is that if i set readAgain
as false (so it doesn't overwrite user selected preference)
only the first call to this method is being performed.
how do i set default values for all my preference xml's?
EDIT:i tried a "hack" for a solution, which is to try and fetch a value that has a default value and if its null, call getDefaultSharedPreferences
with readAgain
as true
. and it did not work (only the first call initialized its values)