what is Android Context and why is it needed

17,453

Solution 1

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.

Solution 2

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

Share:
17,453

Related videos on Youtube

Droidme
Author by

Droidme

Updated on June 04, 2022

Comments

  • Droidme
    Droidme about 2 years

    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.