Tuesday, June 1, 2010

Re: [android-developers] A clear, concise tutorial on PreferenceActivity & Preferences?

Donal Rafferty wrote:
> Thanks Mark.
>
> To access my preferences outside my PreferenceActivity in another
> Activity or a Service can I use PreferenceManager.
> getDefaultSharedPreferences() also?

Yes. That will return the same preferences for this application.

> In your code here:
>
> http://github.com/commonsguy/cw-android/blob/master/Prefs/Dialogs/src/com/commonsware/android/prefdialogs/DialogsDemo.java
>
> I see SharedPreferences prefs=PreferenceManager is used, is that
> correct?

Well, there's more to it than that. You may need to scroll to the right.

I'm going to need to switch to spaces instead of tabs, as my books need
two-space tabs, but GitHub uses eight-space tabs, so my code gets
stretched way out horizontally. :-(

> Should I use it like that to retrieve my preferences eslewhere
> in my application?

Sure.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.5 Available!

--
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

No comments:

Post a Comment