Seems like I must be doing something basic very wrong, but the results are strange, and I'm having trouble tracking the problem down.
This is in my my Activity's onCreate()
PreferenceManager.setDefaultValues(this, R.xml.metronome_preferences, false);
mSharedPrefs=PreferenceManager.getDefaultSharedPreferences(this);
The following code lives in onStart().
Map<String,?> map = mSharedPrefs.getAll();
boolean t = mSharedPrefs.contains("tempo_list_pref");
Log.d(logID, "t= " + t + " preferences=" + map.toString());
mBPMOption = mSharedPrefs.getLong("tempo_list_pref", 100);
Log cat correctly shows:
02-05 11:14:27.605: DEBUG/Metronome(16147): t=true preferences={graphics_list_pref=1, conduct_list_pref=12.0f, tempo_list_pref=140, audio_list_pref=2, meter_list_pref=5}
mBPMOption is a long. The shared prefs object is apparently valid as I can both retrieve the preferences as a map, and test for the presence of a preferences, but the call to getLong() causes ClassCastExceptions to be recursively thrown. At least, that's how I'm interpreting what I'm seeing in the debugger. The error object e contains e.cause, e.cause.cause, ... .
I'm getting this same error in the emulator and on the Google ION dev phone.
Any thoughts on this would be appreciated.