7

Accessing SharedPreference not working in Android

view full story
linux-howto

http://stackoverflow.com – I have two activities. In the first activity, I'm putting a String into a shared preference. I then log the getString and I see that it shows up. I then move onto the second activity, and I Toast the getString and I get the default value that shows up. The first activity code: SharedPreferences.Editor pref_editor = mcontext.getSharedPreferences("Prefs", Context.MODE_PRIVATE).edit(); SharedPreferences pref = mcontext.getSharedPreferences("Prefs", Context.MODE_PRIVATE); pref_editor.putString("test", "It works!").commit(); Log.d("XXX", pref.getString("test", "ERRRROR")); The second activity c (HowTos)