Example usage for android.content Context getApplicationContext

List of usage examples for android.content Context getApplicationContext

Introduction

In this page you can find the example usage for android.content Context getApplicationContext.

Prototype

public abstract Context getApplicationContext();

Source Link

Document

Return the context of the single, global Application object of the current process.

Usage

From source file:Main.java

public static boolean cleanInternalDbByName(Context context, String dbName) {
    return context.getApplicationContext().deleteDatabase(dbName);
}

From source file:Main.java

/**
 * Get application package name/*  w w w .j ava 2s  .c o  m*/
 *
 * @return package name
 */
public static String getPackageName(Context ctx) {
    return ctx.getApplicationContext().getPackageName();
}

From source file:Main.java

public static String getPackageName(Context context) {
    String PACKAGE_NAME = context.getApplicationContext().getPackageName();
    return PACKAGE_NAME;
}

From source file:Main.java

public static File getBaseDirectoryPath(Context context) {
    File cacheDir = context.getApplicationContext().getExternalCacheDir();
    if (cacheDir == null)
        cacheDir = context.getApplicationContext().getCacheDir();
    return cacheDir;
}

From source file:Main.java

public static int getScreenHeight(Context context) {
    DisplayMetrics dm = context.getApplicationContext().getResources().getDisplayMetrics();
    return dm.heightPixels;
}

From source file:Main.java

public static float getDensity(Context context) {
    DisplayMetrics dm = context.getApplicationContext().getResources().getDisplayMetrics();
    return dm.density;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    DisplayMetrics dm = context.getApplicationContext().getResources().getDisplayMetrics();
    return dm.widthPixels;
}

From source file:Main.java

public static String getAppPackageName(Context context) {
    Context applicationText = context.getApplicationContext();
    return applicationText.getPackageName();
}

From source file:Main.java

private static AudioManager getAudioManager(Context context) {
    return (AudioManager) context.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
}

From source file:Main.java

public static void initialize(Context context) {
    sContext = context.getApplicationContext();
}