Wednesday, October 14, 2009

[android-developers] Re: settings page for app design

What I did was to create a singleton class that encapsulated the
preferences. The class has an "update" method that I call when I
return from setting the preferences. Otherwise, as a singleton class
it is available to all activities and units.

As to how I fetch the preferences, I use the following:

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences
(mContext);

try {
colorValue = Integer.parseInt(prefs.getString(mContext.getString
(R.string.pref_color),
mContext.getString(R.string.colordefault)));
}
catch (Exception ex) {
colorValue = 0;
}

Note that in my singleton class I set the context from the main
activity in its create event. The mContext is a reference to that.

HTH

Best Regards,
Eric

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate