Example usage for android.content Context getCacheDir

List of usage examples for android.content Context getCacheDir

Introduction

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

Prototype

public abstract File getCacheDir();

Source Link

Document

Returns the absolute path to the application specific cache directory on the filesystem.

Usage

From source file:Main.java

public static String getCacheFolder(Context context) {
    File cacheFolder = new File(context.getCacheDir().getAbsolutePath() + File.separator + "app_icons");
    if (!cacheFolder.exists()) {
        cacheFolder.mkdir();//  www. jav  a2  s .c o  m
    }
    return cacheFolder.getAbsolutePath();
}

From source file:Main.java

public static File getCacheDir(Context context) {
    File result = context.getCacheDir();
    if (result == null) {
        result = context.getDir("cache", 0);
    }//from  w  w w.  j a  v a 2  s.c om
    if (result == null) {
        result = new File("/data/data/" + context.getPackageName() + "/app_cache");
    }
    if (!result.exists()) {
        result.mkdirs();
    }
    return result;
}

From source file:Main.java

public static void cleanInternalCache(Context context) {
    deleteFilesByDirectory(context.getCacheDir());
}

From source file:Main.java

public static File getCecheFolder(Context context) {
    File folder = new File(context.getCacheDir(), "IMAGECACHE");
    if (!folder.exists()) {
        folder.mkdir();//from ww  w .j av a2 s. com
    }
    return folder;
}

From source file:Main.java

public static String getAppCache(Context context, String dir) {
    String savePath = context.getCacheDir().getAbsolutePath() + "/" + dir + "/";
    File savedir = new File(savePath);
    if (!savedir.exists()) {
        savedir.mkdirs();/*from  ww  w  .  ja v  a2 s. c  o  m*/
    }
    savedir = null;
    return savePath;
}

From source file:Main.java

public static File getBlobPath(Context context) {
    File cachedir = context.getCacheDir();
    if (cachedir == null)
        return null;
    return new File(cachedir.getPath() + File.separatorChar + "blob");
}

From source file:Main.java

public static File getDiskCacheDir(Context context, String file_name) {
    final String cachePath = context.getCacheDir().getPath();
    return new File(cachePath + File.separator + file_name);
}

From source file:Main.java

public static String getAppDataCacheDir(Context context) {
    if (context != null) {
        return context.getCacheDir().getPath();
    }/*from ww w .ja v  a 2  s. co m*/
    return "";
}

From source file:Main.java

@SuppressWarnings("ResultOfMethodCallIgnored")
public static File getAvatarsCacheDir(Context context) {
    File cacheDir = new File(context.getCacheDir(), AVATARS_CACHE_FOLDER);
    if (!cacheDir.exists()) {
        cacheDir.mkdir();//  ww w  . j a  v a  2 s  .co  m
    }
    return cacheDir;
}

From source file:Main.java

public static void setExternalDirPath(Context context) {
    externalDirPath = new File(context.getCacheDir(), "net.hydex11.dynamicbitcodeloader").getAbsolutePath();
}