I have a need to store a single value - the year - so that it can be
called from any activity in my app. Shared Preferences seems to be the
easiest but I've got myself coded into a wall and could use a spot of
advice.

I think the problem is in my XML, but I'm not sure. Here's the
pertinent snip of the java. It should be calling the "setyear"
variable from the settings.xml file:

SharedPreferences myPrefs = getSharedPreferences("settings",
MODE_PRIVATE);
                        final SharedPreferences.Editor prefsEditor = 
myPrefs.edit();

                        int checkme = myPrefs.getInt("setyear", 0);
                        if (checkme < 2011)
                                {
                                prefsEditor.putInt("setyear", 2011);
                        prefsEditor.commit();
                                }

and the XML:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
  xmlns:android="http://schemas.android.com/apk/res/android";
  >
        <EditTextPreference>
                android:key="setyear"
        android:defaultValue="2011"
        </EditTextPreference>
        <EditTextPreference>
                android:key="currlist"
                android:defaultValue="99"
        </EditTextPreference>
</PreferenceScreen>

Suggestions? Did I totally hose myself?

Best, -Larry

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to