Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is Android Context and why is it needed [duplicate]

Possible Duplicate:
What is Context in Android?

I would like to know what exactly Android's Context is, and why it is needed. I know it's related to class and each class has a unique context. I have seen in some code which passes a Context when calling methods of another class. I don't understand why it is needed. Please help.

like image 228
Droidme Avatar asked Mar 23 '11 10:03

Droidme


2 Answers

a Context is:

Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.

Ref: http://developer.android.com/reference/android/content/Context.html

like image 184
Johnny Avatar answered Oct 24 '22 18:10

Johnny


All classes does not have an android context. Their is an application context, and activity c contexts. A context is used for a lot of things, but most often it is just to load and access resources.

See: http://developer.android.com/reference/android/content/Context.html for more info.

like image 42
softcharles Avatar answered Oct 24 '22 19:10

softcharles