Android crashing on ListPreference
<p>I'm trying to add a listpreference to my application. My xml code is the following:</p>

<pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt;
&lt;PreferenceCategory android:title="@string/calendarsettings"&gt;
    &lt;CheckBoxPreference android:key="syncWithCalendar"
        android:title="@string/setting_calendarsync" android:summary="@string/setting_calendarsync"&gt;&lt;/CheckBoxPreference&gt;
    &lt;CheckBoxPreference android:key="calendarAlarm"
        android:title="@string/settings_calendaralarm" android:summary="@string/settings_calendaralarm"&gt;&lt;/CheckBoxPreference&gt;
&lt;/PreferenceCategory&gt;
&lt;PreferenceCategory android:title="@string/filters"&gt;
    &lt;ListPreference android:key="dayFilter" android:title="@string/dayfilter"
        android:summary="@string/dayfilter" android:entries="@array/dayFilterArray"
        android:entryValues="@array/dayFilterValues" /&gt;
&lt;/PreferenceCategory&gt;
 &lt;/PreferenceScreen&gt;
</code></pre>

<p>And my array values are:</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;resources&gt;
&lt;string-array name="dayFilterArray"&gt;
 &lt;item&gt;a&lt;/item&gt;
 &lt;item&gt;b&lt;/item&gt;
 &lt;item&gt;c&lt;/item&gt;
 &lt;item&gt;d&lt;/item&gt;
 &lt;item&gt;e&lt;/item&gt;
 &lt;item&gt;f&lt;/item&gt;
 &lt;item&gt;g&lt;/item&gt;
 &lt;/string-array&gt;
  &lt;string-array name="dayFilterValues"&gt;
 &lt;item&gt;0&lt;/item&gt;
 &lt;item&gt;3&lt;/item&gt;
 &lt;item&gt;7&lt;/item&gt;
 &lt;item&gt;14&lt;/item&gt;
 &lt;item&gt;30&lt;/item&gt;
 &lt;item&gt;90&lt;/item&gt;
 &lt;item&gt;365&lt;/item&gt;
  &lt;/string-array&gt;
 &lt;/resources&gt;
</code></pre>

<p>However when I try to enter my preference menu it crashes with the following exception:</p>

<pre><code>10-03 20:27:56.938: ERROR/AndroidRuntime(1111): Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
</code></pre>

<p>Which refers to this line of code:</p>

<pre><code>    addPreferencesFromResource(R.xml.preferences);
</code></pre>

<p>Any thoughts on this and why is it happening? Thanks.</p>

<p>FULL STACK TRACE:</p>

<pre><code>10-03 21:13:06.828: ERROR/AndroidRuntime(3045): FATAL EXCEPTION: main
10-03 21:13:06.828: ERROR/AndroidRuntime(3045): java.lang.RuntimeException: Unable to start activity ComponentInfo{cPreferencesActivity}: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.app.ActivityThread.access$1500(ActivityThread.java:122)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.os.Looper.loop(Looper.java:132)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.app.ActivityThread.main(ActivityThread.java:4025)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at java.lang.reflect.Method.invokeNative(Native Method)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at java.lang.reflect.Method.invoke(Method.java:491)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at dalvik.system.NativeStart.main(Native Method)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045): Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:203)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.Preference.getPersistedString(Preference.java:1367)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.ListPreference.onSetInitialValue(ListPreference.java:278)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.Preference.dispatchSetInitialValue(Preference.java:1283)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.Preference.onAttachedToHierarchy(Preference.java:1095)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.PreferenceGroup.addPreference(PreferenceGroup.java:156)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:97)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:38)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.GenericInflater.rInflate(GenericInflater.java:488)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.GenericInflater.inflate(GenericInflater.java:326)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.GenericInflater.inflate(GenericInflater.java:263)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:269)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:1333)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at PreferencesActivity.onCreate(PreferencesActivity.java:33)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
10-03 21:13:06.828: ERROR/AndroidRuntime(3045):     ... 11 more
</code></pre>
