For example, our preferences.xml file was added by addPreferencesFromResource (R.xml.preferences).
Our preferences.xml file contains such item:
<ListPreference android:id="@+id/order_by" android:key="@string/pref_sort_key"
android:title="@string/pref_sort_title" android:summary="@string/pref_sort_summary"
android:dialogTitle="@string/pref_sort_dialog_title" android:entries="@array/sort_oder"
android:entryValues="@array/sort_oder_value"
android:defaultValue="@string/pref_default_sort_value" app:iconSpaceReserved="false" />
In our Fragment, we can dynamically get current notification preference value in this way:
A . String sortBy = PreferenceManager.getDefaultSharedPreferences(getContext
()).getString(
getContext().getString(
B . string.pref_sort_key),
getContext().getResources().getBoolean(
C . bool.pref_default_sort_value)
);
D . String sortBy = PreferenceManager.getSharedPreferences(getContext()).getString( getContext().getString(
E . string.pref_default_sort_value), getContext().getString(
F . string.pref_sort_key) );
G . boolean sortBy = PreferenceManager.getSharedPreferences(getContext()).getBoolean ( getContext().getResources().getBoolean(
H . bool.pref_default_sort_value), getContext().getString(
. string.pref_sort_key) );
. String sortBy = PreferenceManager.getDefaultSharedPreferences(getContext
()).getString(
getContext().getString(
. string.pref_sort_key), getContext().getString(
. string.pref_default_sort_value) )
Answer: D
Leave a Reply