On the use of setSharedPreferencesName PreferenceFragment in the ListPreference

I have a set of Activity, using PreferenceFragment implementation, the use of getPreferenceManager in Fragment (.SetSharedPreferencesName) ("settings_preference") to change the default settings file, the code as follows:
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.getPreferenceManager().setSharedPreferencesName("settings_preference");
//this.getPreferenceManager().setSharedPreferencesMode(Context.MODE_PRIVATE);
addPreferencesFromResource(R.xml.preferences);
}

Preferences file as follows:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
android:title="GPS positioning"
android:enabled="true"
android:key="openGPS"
android:summary="Whether to open the GPS positioning"
android:selectable="false"
android:defaultValue="false"/>

<ListPreference
android:title="The frequency of positioning"
android:key="@string/locFrequence"
android:entries="@array/auto_update_frequency_entry"
android:entryValues="@array/auto_update_frequency_value"
/>

Thus the use of the ListPreference, open the settings of the Activity in the interface will be wrong:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gmy.myrouting/com.gmy.myrouting.SettingsActivity}: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

Positioning is: addPreferencesFromResource (R.xml.preferences); this one line of code error.
But, when I commented out code (this.getPreferenceManager).SetSharedPreferencesName ("settings_preference"); when, not wrong, and when I removed the ListPreference label, no error. I do not know what to do. You do me a favor! Thanked....

Started by Gene at December 20, 2016 - 5:45 PM

How did not answer.

Posted by Antoine at January 01, 2017 - 5:59 PM