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:com.joker.gankor.utils.ASimpleCache.java

public static ASimpleCache get(Context ctx, String cacheName) {
    File f = new File(ctx.getCacheDir(), cacheName);
    return get(f, MAX_SIZE, MAX_COUNT);
}

From source file:com.yixia.zi.utils.ImageCache.java

/**
 * Get a usable cache directory (external if available, internal otherwise).
 * /*from w  ww .  ja va2 s.com*/
 * @param context The context to use
 * @param uniqueName A unique directory name to append to the cache dir
 * @return The cache dir
 */
public static File getDiskCacheDir(Context context, String uniqueName) {

    // Check if media is mounted or storage is built-in, if so, try and use external cache dir
    // otherwise use internal cache dir
    String cachePath = "";
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            && !isExternalStorageRemovable()) {
        cachePath = getExternalCacheDir(context).getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    return new File(cachePath + File.separator + uniqueName);
}

From source file:cn.scau.scautreasure.util.CacheUtil.java

public static CacheUtil get(Context ctx, String cacheName) {
    File f = new File(ctx.getCacheDir(), cacheName);
    return get(f, MAX_SIZE, MAX_COUNT);
}

From source file:com.apkbus.mobile.utils.ACache.java

public static ACache get(Context ctx, String cacheName) {
    File f = new File(ctx.getCacheDir(), cacheName);
    //File f = new File(ctx.getExternalCacheDir(), cacheName);
    return get(f, MAX_SIZE, MAX_COUNT);
}

From source file:com.egoists.coco_nut.android.cache.ImageCache.java

/**
 * Get a usable cache directory (external if available, internal otherwise).
 * //www  .j  ava 2  s . c  om
 * @param context The context to use
 * @param uniqueName A unique directory name to append to the cache dir
 * @return The cache dir
 */
public static File getDiskCacheDir(Context context, String uniqueName) {

    // Check if media is mounted or storage is built-in, if so, try and use
    // external cache dir
    // otherwise use internal cache dir
    final String cachePath = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !isExternalStorageRemovable() ? getExternalCacheDir(context).getPath()
                    : context.getCacheDir().getPath();

    return new File(cachePath + File.separator + uniqueName);
}

From source file:com.android.volley.misc.Utils.java

/**
 * Get a usable cache directory (external if available, internal otherwise).
 * /*from   ww w  .  ja v  a2s .  co  m*/
 * @param context
 *            The context to use
 * @param uniqueName
 *            A unique directory name to append to the cache dir
 * @return The cache dir
 */
public static File getDiskCacheDir(Context context, String uniqueName) {
    // Check if media is mounted or storage is built-in, if so, try and use
    // external cache dir
    // otherwise use internal cache dir

    // TODO: getCacheDir() should be moved to a background thread as it
    // attempts to create the
    // directory if it does not exist (no disk access should happen on the
    // main/UI thread).
    final String cachePath;
    if (isExternalMounted() && null != getExternalCacheDir(context)) {
        cachePath = getExternalCacheDir(context).getPath();
    } else {
        cachePath = context.getCacheDir().getPath();
    }

    Log.i("Cache dir", cachePath + File.separator + uniqueName);
    return new File(cachePath + File.separator + uniqueName);
}

From source file:caesar.feng.framework.utils.ACache.java

public static ACache get(Context ctx, long max_zise, int max_count) {
    File f = new File(ctx.getCacheDir(), "ACache");
    return get(f, max_zise, max_count);
}

From source file:com.joker.gankor.utils.ASimpleCache.java

public static ASimpleCache get(Context ctx, long max_zise, int max_count) {
    File f = new File(ctx.getCacheDir(), "ASimpleCache");
    return get(f, max_zise, max_count);
}

From source file:cn.scau.scautreasure.util.CacheUtil.java

public static CacheUtil get(Context ctx, long max_zise, int max_count) {
    File f = new File(ctx.getCacheDir(), "CacheUtil");
    return get(f, max_zise, max_count);
}

From source file:com.apkbus.mobile.utils.ACache.java

public static ACache get(Context ctx, long max_zise, int max_count) {
    File f = new File(ctx.getCacheDir(), "ACache");
    //File f = new File(ctx.getExternalCacheDir(), "ACache");
    return get(f, max_zise, max_count);
}