How to Get the Global Application Context

public abstract Context getApplicationContext () was added in API level 1
Return the context of the single, global Application object of the current process. This generally should only be used if you need a Context whose lifecycle is separate from the current context, that is tied to the lifetime of the process rather than the current component.

1. Declare a Context object named myContext.

2. In the onCreate method, add the below line. This will return the context of the single, global Application object of the current process and save it to the context object named myContext.

myContext = getApplicationContext();

3. Compile and run!