Search code examples
androidandroid-preferences

Android Preferences defaultValue not works


Here is my preferences.xml

<PreferenceCategory android:title="@string/pref_cat_recognition">
    <ListPreference
        android:entries="@array/unitsArray"
        android:entryValues="@array/unitsValues"
        android:icon="@null"
        android:key="unit"
        android:summary="@string/units_summary"
        android:title="@string/units"
        android:defaultValue="1"/>
</PreferenceCategory>

and my array.xml

<string-array name="unitsArray" translatable="false">
    <item>cm</item>
    <item>inch</item>
</string-array>

<string-array name="unitsValues" translatable="false">
    <item>1</item>
    <item>2</item>
</string-array>

So it should be cm checked on start but there is no value checked. Why and how to solve that to have a value cm on start?


Solution

  • It turned out in manifest I had android:allowBackup="true"