I am reading shared preferences like
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
and then with preferences.getString("list_of_text_modes", "0") i can get value of any shared preferences. In my example (0 or 1)
Is it possible to get title too, not just value?
For example. I am using ListPreference.
<ListPreference
android:entries="@array/list_of_text_modes"
android:entryValues="@array/list_of_text_mode_values"
android:key="list_of_text_modes"
android:summary=""
android:title="@string/title_language_mode"
android:defaultValue="default" />
<string-array name="list_of_text_modes">
<item>Default</item>
<item>Settings</item>
</string-array>
<string-array name="list_of_text_mode_values">
<item>0</item>
<item>1</item>
now i get “0” if i choose “Default”. Can i read somehow title “Default”. Or with preferences i can read only values?
And what if I don’t have 0 and 1. What if i save as “text1” and “tetx2”. Can i read by key, value pair?
You can extract titles from your resources, if you have title index. Try this code: