I would bet that you are accessing a different set of preferences than the ones you're saving in the preference screen.
The Preference screen uses the preference file returned from PreferenceManager.getDefaultSharedPreferences(context); (context will typically be 'this' -- your activity). If you call getPreferences() on the activity, it returns one that is private to the activity, which isn't what you want here. On Nov 21, 11:43 am, "Claudio M. Camacho" <claudio...@gmail.com> wrote: > Hello everybody, > > This is my first question. I tried to ask in android-beginners, but > the group is discontinued. > > My problem is using SharedPreferences. I just created a > <PreferenceScreen> which holds inside a <ListPreference> with an array > of 5 different values. Very simple! The array of values are different > numbers: 1, 2, 5, 10 and 30. > > Every time I change the setting, the application remembers that and I > can see the setting I chose when I access the preferences once again > (as an user). Now, in the code, when I retrieve the setting using the > key (e.g. getString("delay", default_delay);), I always get the > default value, it seems that the SharedPreferences does not find my > setting. > > Can anybody help? I have read about > SharedPreferences.getEditor().commit(), but that should be used only > when changing settings from the code, not from the UI preferences. > > Anyone had this problem before? > > P.S.- I use Froyo 2.2 to run the application (on a Samsung Galaxy S). > > --Claudio -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en