I am trying to create a time selection preference by extending the DialogPreference
. I have specified a android:defaultValue
in the Preference XML. Everything works well, but when I try to read the value of the preference from code, I get an empty string. Ideally, if the preference is not set, I should get the value as 5:00 which is mentioned asandroid:defaultValue
in the Preference XML.
When I retrieve the preference, how can I get the value specified as
android:defaultValue
in the Preference XML, if user has not yet set the preference?
<com.sample.package.TimeDialogPreference
android:defaultValue="5:00"
android:key="@string/pref_key_time"
android:title="@string/pref_title_time"
android:summary="@string/pref_summary_time"
android:dialogLayout="@layout/preference_time"
/>