I get the following warning for each of my XML preferences 
and I understand java thinks the default values I gave are integers, and it expects strings. But how do I put a literal string?
I can live with the warning, since I know it is harmless, but if there is a simple way to correct it I will.
05-16 16:28:03.210: I/ActivityManager(68): Starting activity: Intent { cmp=com.delta.app/.Preferences }
05-16 16:28:03.750: W/Resources(1869): Converting to string: TypedValue{t=0x10/d=0x1388 a=-1}
05-16 16:28:03.870: W/Resources(1869): Converting to string: TypedValue{t=0x10/d=0x64 a=-1}
05-16 16:28:03.901: W/Resources(1869): Converting to string: TypedValue{t=0x10/d=0xa a=-1}
05-16 16:28:03.970: W/Resources(1869): Converting to string: TypedValue{t=0x10/d=0x0 a=-1}
05-16 16:28:03.970: W/Resources(1869): Converting to string: TypedValue{t=0x10/d=0x2 a=-1}
Here is the XML:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<EditTextPreference
    android:defaultValue="5000"
    android:key="@string/MAX_MESSAGES"
    android:summary="@string/MAX_MESSAGES_desc"
    android:title="@string/MAX_MESSAGES_title" />
<EditTextPreference
    android:defaultValue="100"
    android:key="@string/VIEW_MAX_ROWS"
    android:summary="@string/VIEW_MAX_ROWS_desc"
    android:title="@string/VIEW_MAX_ROWS_title" />
<EditTextPreference
    android:defaultValue="10"
    android:key="@string/VIEW_EDGE_ROWS"
    android:summary="@string/VIEW_EDGE_ROWS_desc"
    android:title="@string/VIEW_EDGE_ROWS_title" />
<ListPreference
    android:defaultValue="0"
    android:entries="@array/level_list"
    android:entryValues="@array/level_values"
    android:key="@string/INITIAL_ORG"
    android:summary="@string/INITIAL_ORG_desc"
    android:title="@string/INITIAL_ORG_title" />
<ListPreference
    android:defaultValue="2"
    android:entries="@array/view_list"
    android:entryValues="@array/view_values"
    android:key="@string/INITIAL_VIEW"
    android:summary="@string/INITIAL_VIEW_desc"
    android:title="@string/INITIAL_VIEW_title" />
<CheckBoxPreference
    android:defaultValue="true"
    android:key="@string/AUTOSCROLL"
    android:summary="@string/AUTOSCROLL_desc"
    android:title="@string/AUTOSCROLL_title" />
<CheckBoxPreference
    android:defaultValue="true"
    android:key="@string/SEND_THEN_EXIT"
    android:summary="@string/SEND_THEN_EXIT_desc"
    android:title="@string/SEND_THEN_EXIT_title" />
<Preference
    android:key="@string/DEFAULT_PREFS"
    android:summary="@string/DEFAULT_PREFS_desc"
    android:title="@string/DEFAULT_PREFS_title" />
</PreferenceScreen>
                Add this line in string.xml
<string name="five_thousand">5000</string>
ans set it in defaultvalue..you can do it for others defaultvalue...
<EditTextPreference
    android:defaultValue="@string/five_thousand"
    android:key="@string/MAX_MESSAGES"
    android:summary="@string/MAX_MESSAGES_desc"
    android:title="@string/MAX_MESSAGES_title" />
                        Double quoting every defaultValue got rid of the warnings for me, but it created other issues:
<EditTextPreference
    android:defaultValue="'5000'"
    android:key="@string/MAX_MESSAGES"
    android:summary="@string/MAX_MESSAGES_desc"
    android:title="@string/MAX_MESSAGES_title" />
While the defaultValue is a string to XML, it seems that the outer quotes get stripped before being sent to java.
But when you try to edit the preference in the Android app, the box now contains the string '5000' instead of the number 5000, which can lead to other problems.
If we have to tolerate either unnecessary warnings or invalid fields, I suppose the former is the only real option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With