Using the Application Context

The application context is the central location for all top-level application functionality. You use the application context to access settings and resources shared across multiple activity instances.

You can retrieve the application context for the current process by using the getApplicationContext() method, like this: Context context = getApplicationContext();

Because the Activity class is derived from the Context class, you can use this instead of retrieving the application context explicitly.


Was this article helpful?

0 0

Post a comment