title: java.lang.Integer cannot be cast to java.lang.String on addPreferencesFromResource
body: <p>I have an example about <code>Preferences</code> like this:</p>
  <pre><code>public class UserPreferences extends PreferenceActivity {
      @Override
      public void onCreate(Bundle saveInstanceState){
          super.onCreate(saveInstanceState);
          getFragmentManager().beginTransaction().replace(android.R.id.content, new MynewFracment()).commit();
      }
      public static class MynewFracment extends PreferenceFragment{
          @Override
          public void onCreate(Bundle saveInstanceState){
              super.onCreate(saveInstanceStates);
              addPreferencesFromResource(R.xml.userpreference);
          }
      }
  }
  </code></pre>
  <p>But the result return is <code> java.lang.Integer cannot be cast to java.lang.String</code> on the line <code>addPreferencesFromResource(R.xml.userpreferences);</code> . I really don't know what did I do wrong here?</p>
  <hr />
  <h2>Update 1</h2>
  <pre><code>&lt;PreferenceScreen xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
      &lt;CheckBoxPreference
          android:key=&quot;PREF_AUTO_UPDATE&quot;
          android:title=&quot;Auto refresh&quot;
          android:summary=&quot;Select to turn on automatic updateing&quot;
          android:defaultValue=&quot;true&quot;
          &gt;&lt;/CheckBoxPreference&gt;
      &lt;ListPreference
          android:key=&quot;PREF_UPDATE_FREQ&quot;
          android:title=&quot;Refresh frequency&quot;
          android:summary=&quot;Frequency at which to refresh earthquake list&quot;
          android:entries=&quot;@array/update_freq_option&quot;
          android:entryValues=&quot;@array/update_freq_values&quot;
          android:dialogTitle=&quot;Refresh frequency&quot;
          android:defaultValue=&quot;60&quot;
          &gt;&lt;/ListPreference&gt;
      &lt;ListPreference
          android:key=&quot;PREF_MIN_MAG&quot;
          android:title=&quot;Minimum magnitude&quot;
          android:summary=&quot;Select the minimum magnitude earthquake to report&quot;
          android:entries=&quot;@array/magnitude_options&quot;
          android:entryValues=&quot;@array/magnitude&quot;
          android:dialogTitle=&quot;Magnitude&quot;
          android:defaultValue=&quot;3&quot;
          &gt;&lt;/ListPreference&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  <hr />
  <h2>Update 2</h2>
  <p>My R.values</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;resources&gt;
      &lt;string-array name=&quot;update_freq_option&quot;&gt;
          &lt;item&gt;Every Minutes&lt;/item&gt;
          &lt;item&gt;5 mins&lt;/item&gt;
          &lt;item&gt;10 mins&lt;/item&gt;
          &lt;item&gt;15 mins&lt;/item&gt;
          &lt;item&gt;Every Hours&lt;/item&gt;
      &lt;/string-array&gt;
  
      &lt;array name=&quot;magnitude&quot;&gt;
          &lt;item&gt;3&lt;/item&gt;
          &lt;item&gt;5&lt;/item&gt;
          &lt;item&gt;6&lt;/item&gt;
          &lt;item&gt;7&lt;/item&gt;
          &lt;item&gt;8&lt;/item&gt;
      &lt;/array&gt;
  
      &lt;string-array name=&quot;magnitude_options&quot;&gt;
          &lt;item&gt;3&lt;/item&gt;
          &lt;item&gt;5&lt;/item&gt;
          &lt;item&gt;6&lt;/item&gt;
          &lt;item&gt;7&lt;/item&gt;
          &lt;item&gt;8&lt;/item&gt;
      &lt;/string-array&gt;
  
      &lt;array name=&quot;update_freq_values&quot;&gt;
          &lt;item&gt;1&lt;/item&gt;
          &lt;item&gt;5&lt;/item&gt;
          &lt;item&gt;10&lt;/item&gt;
          &lt;item&gt;15&lt;/item&gt;
          &lt;item&gt;60&lt;/item&gt;
      &lt;/array&gt;
  &lt;/resources&gt;
  </code></pre>
  <p>And my stacktrace</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                                                                       java.lang.RuntimeException: Unable to start activity ComponentInfo{com.begood.earthquake/com.begood.earthquake.UserPreferences}: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                                           at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                           at android.os.Looper.loop(Looper.java:137)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                           at java.lang.reflect.Method.invokeNative(Native Method)
                                                                           at java.lang.reflect.Method.invoke(Method.java:511)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                           at dalvik.system.NativeStart.main(Native Method)
                                                                        Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
                                                                           at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:205)
                                                                           at android.preference.Preference.getPersistedString(Preference.java:1399)
                                                                           at android.preference.ListPreference.onSetInitialValue(ListPreference.java:278)
                                                                           at android.preference.Preference.dispatchSetInitialValue(Preference.java:1315)
                                                                           at android.preference.Preference.onAttachedToHierarchy(Preference.java:1127)
                                                                           at android.preference.PreferenceGroup.addPreference(PreferenceGroup.java:156)
                                                                           at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:97)
                                                                           at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:38)
                                                                           at android.preference.GenericInflater.rInflate(GenericInflater.java:488)
                                                                           at android.preference.GenericInflater.inflate(GenericInflater.java:326)
                                                                           at android.preference.GenericInflater.inflate(GenericInflater.java:263)
                                                                           at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:269)
                                                                           at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:278)
                                                                           at com.begood.earthquake.UserPreferences$MynewFracment.onCreate(UserPreferences.java:20)
                                                                           at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:796)
                                                                           at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
                                                                           at android.app.BackStackRecord.run(BackStackRecord.java:635)
                                                                           at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
                                                                           at android.app.Activity.performStart(Activity.java:5017)
                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
                                                                           at android.app.ActivityThread.access$600(ActivityThread.java:130) 
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
                                                                           at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                           at android.os.Looper.loop(Looper.java:137) 
                                                                           at android.app.ActivityThread.main(ActivityThread.java:4745) 
                                                                           at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                           at java.lang.reflect.Method.invoke(Method.java:511) 
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
                                                                           at dalvik.system.NativeStart.main(Native Method) 
  </code></pre>