I'm using the PreferenceManagers method to inflate a set of
application preferences from an xml file. Here is my code:

PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

Here is my preferences.xml file (I've yanked it from another website
for testing purposes):

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/
android">
        <PreferenceCategory
                android:title="First Category">
                <CheckBoxPreference
                        android:title="Checkbox Preference"
                        android:defaultValue="false"
                        android:summary="This preference can be true
or false"
                        android:key="checkboxPref" />
        </PreferenceCategory>
        <PreferenceCategory
                android:title="Second Category">
        <EditTextPreference
                android:name="EditText Preference"
                android:summary="This allows you to enter a string"
                android:defaultValue="Nothing"
                android:title="Edit This Text"
                android:key="editTextPref" />
        <RingtonePreference
                android:name="Ringtone Preference"
                android:summary="Select a ringtone"
                android:title="Ringtones"
                android:key="ringtonePref" />
        <PreferenceScreen
                android:key="SecondPrefScreen"
                android:title="Second PreferenceScreen"
                android:summary="This is a second PreferenceScreen">
                <EditTextPreference
                        android:name="An other EditText Preference"
                        android:summary="This is a preference in the
second PreferenceScreen"
                        android:title="Edit text"
                        android:key="SecondEditTextPref" />
        </PreferenceScreen>
        <Preference
                android:title="Custom Preference"
                android:summary="This works almost like a button"
                android:key="customPref" />
        </PreferenceCategory>
</PreferenceScreen>

Sure enough, Android creates a shared preferences file on the virtual
device, pulling the file from the device however reveals that only the
EditTextPreference was saved. Here's how the test.test_preferences.xml
file from the device looks:

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="editTextPref">Nothing</string>
</map>

I've also tried setting:

 PreferenceManager.setDefaultValues(this, R.xml.preferences, true);

With the same result, so it's not because it's just using an old
shared prefs file. What gives?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to