In Android programming, what exactly is a Context
class and what is it used for?
I read about it on the developer site, but I am unable to understand it
Context
is an "interface" to the global information about an application environment. In practice, Context
is actually 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.
In the following picture, you can see a hierarchy of classes, where Context
is the root class of this hierarchy. In particular, it's worth emphasizing that Activity
is a descendant of Context
.