I'm not sure if this is an Android question or just due to my being
new to Java as well. I'd like to use the getString method to get
strings from my resources (R.string.whatever). I see that this is a
method of the Context class, and I can call it directly from within my
main Activity class.

But I also have some utility classes in their own class files and
can't simply call this method from them. What seems to be required is
for me to pass the context (the Activity object) into these other
classes via their constructors. Then I can call the method e.g.,
mCtx.getString().

Am I correct that this is the only way to do this? Also, if I want to
use any other Android class that requires a context (e.g.
AlertDialog.Builder), I essentially have to "pass" the context from
the main Activity object to any class that needs to use it?

I guess my main question is whether there's another way to get the
Context without having to pass it from class to class as an argument.

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

Reply via email to