I have a Preference activity which uses a List Preferences as defined by my XML file:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="sync">
<ListPreference
android:key="key_sync_period"
android:title="Sync"
android:summary="%s"
android:dialogTitle="Sync frequency"
android:entries="@array/sync_period_entries"
android:entryValues="@array/sync_period_values"
android:defaultValue="1800" />
</PreferenceCategory>
</PreferenceScreen>
arrays.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="sync_period_entries">
<item>15 min</item>
<item>30 min</item>
<item>45 min</item>
<item>1 hour</item>
</string-array>
<string-array name="sync_period_values">
<item>900</item>
<item>1800</item>
<item>2700</item>
<item>3600</item>
</string-array>
</resources>
When I start my app, change this setting, I see the following:
Why do I see these values (60, 180)? Where did they come from?
Update 1:
if (key.equals("key_sync_period"))
{
ListPreference syncPref = (ListPreference) findPreference(key);
syncPref.setSummary(syncPref.getEntry());
long seconds = Long.valueOf(sharedPreferences.getString(key, "1800"));
}
The system writes defaultSharedPreferences. I see preference file from ddms and see that the system written wrong value.
The problem was in the Idea 12CE, I deleted the project and imported it again... and problem was solved.