Example usage for android.content Context getExternalCacheDir

List of usage examples for android.content Context getExternalCacheDir

Introduction

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

Prototype

@Nullable
public abstract File getExternalCacheDir();

Source Link

Document

Returns absolute path to application-specific directory on the primary shared/external storage device where the application can place cache files it owns.

Usage

From source file:Main.java

public static String getCachePath(Context c) {
    return c.getExternalCacheDir().getAbsolutePath();
}

From source file:Main.java

public static File getCacheDir(Context c) {
    File cacheDir = c.getExternalCacheDir();

    if (null == cacheDir)
        cacheDir = c.getCacheDir();/*  w  w  w  . j  ava  2  s. c  om*/

    if (!cacheDir.exists())
        cacheDir.mkdirs();

    return cacheDir;
}

From source file:Main.java

private static File getAppCacheDir(Context context) {
    return context.getExternalCacheDir();
}

From source file:Main.java

public static File getKustomPreviewCache(@NonNull Context context) {
    return new File(context.getExternalCacheDir(), "KustomPreviews");
}

From source file:Main.java

private static File getTempFile(Context context) {
    File imageFile = new File(context.getExternalCacheDir(), TEMP_IMAGE_NAME);
    imageFile.getParentFile().mkdirs();/*w  w  w .  j  a  va  2s .  co  m*/
    return imageFile;
}

From source file:Main.java

public static File getCacheFullFileName(Context context, String filename) {
    File dir = context.getExternalCacheDir();
    File imgDir = new File(dir, "images");
    imgDir.mkdirs();//from   ww w .j ava2s  . com
    return new File(imgDir, filename);
}

From source file:Main.java

public static String getDirectory(Context context) {
    return context.getExternalCacheDir() + File.separator + "NightMode";
}

From source file:Main.java

/**
 * Get the folder where temporary files from the camera are stored.
 *
 * @return The temp folder./* ww w  .j a  va  2s  .  co m*/
 */
@NonNull
public static File getTempCameraFolder(final Context c) {
    File result = new File(c.getExternalCacheDir(), "Camera");
    if (!result.exists()) {
        //noinspection ResultOfMethodCallIgnored
        result.mkdirs();
    }
    return result;
}

From source file:Main.java

public static File getCacheDir(Context context) {
    return isExternalStorageWritable() ? context.getExternalCacheDir() : context.getCacheDir();
}

From source file:Main.java

public static File getExternalCacheDir(Context context, String type) {
    File cacheDir = new File(context.getExternalCacheDir(), type);
    cacheDir.mkdirs();//from  w ww  .  j a  v  a 2 s .  c  o m
    return cacheDir;
}