Sunday, 8 July 2018

add specific named SharedPreferences from resource in PreferenceActivity or PreferenceFragment

If I have a Preference-Activity or -Fragment I can provide a preference.xml file to build my PreferenceScreen and show it via addPreferenceFromResource(R.xml.preference)

Changed values can then be retrieved by PreferenceManager.getDefaultSharedPreferences(Context)

I'm just wondering if it is possible to take other than the default Preferences for my Fragment.

I want to have a PreferenceFragment that is able to store its Preferences (provided via xml) in Preferences I can retrieve via context.getSharedPreferences("customPrefName", Context.MODE_PRIVATE) but I couldn't find something in the xml like

<PreferenceScreen android:prefName="customPrefName">...



from add specific named SharedPreferences from resource in PreferenceActivity or PreferenceFragment

No comments:

Post a Comment