Issue
When I try to read the default value of my "sync_frequency" in the SharedPreferences it returns 30 but should 300000.
My resources:
<resources>
<string name="pref_title_sync_frequency">Intervall</string>
<string-array name="pref_sync_frequency_titles">
<item>5 min.</item>
<item>10 min.</item>
<item>15 min.</item>
<item>20 min.</item>
<item>30 min.</item>
<item>60 min.</item>
<item>Nimals</item>
</string-array>
<string-array name="pref_sync_frequency_values">
<item>300000</item>
<item>600000</item>
<item>900000</item>
<item>1200000</item>
<item>1800000</item>
<item>3600000</item>
<item>-1</item>
</string-array>
</resources>
My Preference page:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:defaultValue="300000"
android:entries="@array/pref_sync_frequency_titles"
android:entryValues="@array/pref_sync_frequency_values"
android:key="sync_frequency"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:title="@string/pref_title_sync_frequency" />
<SwitchPreference
android:defaultValue="true"
android:dependency="sync_frequency"
android:key="sync_appoint_only_on_wifi"
android:title="@string/pref_title_on_wifi_appo" />
<SwitchPreference
android:defaultValue="true"
android:dependency="sync_frequency"
android:key="sync_feed_only_on_wifi"
android:title="@string/pref_title_on_wifi_feed" />
The way I try to get the value:
public int syncIntervall(){
SharedPreferences spr = PreferenceManager.getDefaultSharedPreferences(ctx);
return Integer.valueOf(spr.getString("sync_frequency", "300000"));
}
Returns 30;
Solution
The problem was that the applications Preference cache does not reset itself by installing an new version of the app. I had to uninstall the app by hand.
Answered By - Neuxz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.