I use SharedPreferences for settings in the application.
There is an EditTextPreference in which some default value is set. How to get it now? (assign to variable)
Settings menu file:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:title="@string/pref_user_profile" > <EditTextPreference android:title="@string/pref_user_id_summary" android:summary="@string/pref_user_id_description" android:defaultValue="@string/pref_user_id_default_value" android:key="prefUserId"/> </PreferenceCategory> In activit, I'm trying to get something like this:
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); id_num = sharedPrefs.getString("prefUserId", ""); In the second quotes, as I understand it, the default value is set. But this is not the value that is in the field defaultValue . How to get it?