Go back

Context In Android

Published on 9 May, 2025

Suppose, you create an android app which would like to access some user permission on runtime, let’s say notification. How can your app do that? How will your app knows, if the permission is already granted to your app or not? If not granted, how can it request the android system to provide a dialog to request permission from the user?

Well, that’s where context comes into play. A Context will provide our app with all the information about this permission and other resources available for our app to utilize.

What is Context

A Context refers to an environment or the state of the application. In other words, it is like a bridge that lets you interact with Android’s operating system and your app’s internal resources.

Role of Context

Context are used for many different things in our application. Few key roles that context plays in our applications are:

  1. Access resources such as Strings, colors, drawables, etc
  2. Access Files and cache directories
  3. Access Locally stored information
  4. Start activities, services and sending broadcasts.
  5. Access system services
  6. Check/request permissions

Types of Contexts

There are different types of context based on where and how they’re used:

1. Application Context

2. Activity Context

3. Service Context

4. BroadcastReceiver Context

5. ContentProvider Context

Hence, this was all the basics , you need to know about contexts in android.