Neither of my ListPreference values persist from one run to the next.
Sometimes even in the same run, if I bring up preferences the
ListPreference values will be back to the default values.

Here is the Settings xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen 
        xmlns:android="http://schemas.android.com/apk/res/android";>
        <EditTextPreference 
                android:key="weight"
                android:title="@string/weightlbltxt"
                android:defaultValue="145"
                />
        <ListPreference
            android:title="@string/genderlbltxt"
                android:entries="@array/genders"
                android:entryValues="@array/gendervalues"
                android:defaultValue="M"
                />
        <ListPreference
                android:title="@string/alarmlbltxt"
                android:entries="@array/alarms"
                android:entryValues="@array/alarmvalues"
                android:defaultValue="N"
                />
        <EditTextPreference
                android:key="BAC"
                android:title="@string/baclbltxt"
                android:defaultValue="0.08"
                />
</PreferenceScreen>

Here are the string-array values:

        <string-array name="genders">
                <item>Male</item>
                <item>Female</item>
        </string-array>
        
        <string-array name="gendervalues">
                <item>M</item>
                <item>F</item>
        </string-array>

        <string-array name="alarms">
                <item>None</item>
                <item>Ring Tone</item>
                <item>Vibrate</item>
        </string-array>
        
        <string-array name="alarmvalues">
                <item>N</item>
                <item>R</item>
                <item>V</item>
        </string-array>

Here is the Settings.java:

package com.parisj13.trackmydrinks;

import android.content.Context;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

public class Settings extends PreferenceActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState){
                super .onCreate(savedInstanceState);
                addPreferencesFromResource(R.layout.settings);
                //setContentView(R.layout.settings);
        }
        
        public static int GetWeight(Context context){
                return PreferenceManager.getDefaultSharedPreferences(context)
                .getInt("weight", 145);
        }
        
        public static String GetGender(Context context){
                return  PreferenceManager.getDefaultSharedPreferences(context)
                .getString("gender", "Male");
        }
        
        public static String GetAlarm(Context context){
                return PreferenceManager.getDefaultSharedPreferences(context)
                .getString("alarm", "None");
        }
        
        public static int GetBAC(Context context){
                return PreferenceManager.getDefaultSharedPreferences(context)
                .getInt("BAC", 145);
        }
}

Here is the Console, that shows something strange:
2009-05-13 21:28:37 - DeviceMonitor]Error reading jdwp list: EOF
[2009-05-13 22:05:10 - DeviceMonitor]Error reading jdwp list: EOF
[2009-05-13 22:05:11 - DeviceMonitor]Connection Failure when starting to
monitor device 'emulator-5554' : device (emulator-5554) request
rejected: device not found
[2009-05-13 22:13:38 - Logcat]device (emulator-5554) request rejected:
device not found
java.io.IOException: device (emulator-5554) request rejected: device not
found
        at com.android.ddmlib.AdbHelper.setDevice(Unknown Source)
        at com.android.ddmlib.AdbHelper.executeRemoteCommand(Unknown Source)
        at com.android.ddmlib.Device.executeShellCommand(Unknown Source)
        at com.android.ddmuilib.logcat.LogPanel$3.run(Unknown Source)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to