Only CheckboxPreference keys with android: defaultValue = "true" will be displayed in the code below. Thus, none of the keys with defaultValue = "false" is displayed. How do I get a list of all the keys in my preferences file?
PreferenceManager.setDefaultValues(this,R.xml.settings,true); //readAgain=false is same result SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this); Map<String, ?> prefMap=prefs.getAll(); for(String key:prefMap.keySet()) { Log.d("preference key=",key); //only keys with true are shown } }
According to the docs, getAll () should: "Extract all values ββfrom settings." However, apparently, only keys that have a default value = true if the preference was not set by the user later.
EDIT: This is probably due to Android Bug: 6441 , but does not give me a workaround to get all the keys.
source share