Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Static Application Context Method
In Android Manifest file declare following
<application android:name="">
then write the class
public class MyApplication extends Application{
private static Context context;
public void onCreate(){
MyApplication.context = getApplicationContext();
public static Context getAppContext() {
return MyApplication.context;
Now every where call MyApplication.getAppContext() to get your application context statically.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment