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
If you want to connect Context with other familiar classes in Android, keep in mind this structure:
Context < ContextWrapper < Application
Context < ContextWrapper < ContextThemeWrapper < Activity
Context < ContextWrapper < ContextThemeWrapper < Activity < ListActivity
Context < ContextWrapper < Service
Context < ContextWrapper < Service < IntentService
So, all of those classes are contexts in their own way. You can cast Service and ListActivity to Context if you wish. But if you look closely, some of the classes inherit theme as well. In activity or fragment, you would like theming to be applied to your views, but don't care about it Service class, for instance.
I explain the difference in contexts here.