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:com.nf2m.util.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use//  w w w .  ja v a  2 s  .  co m
 * @return The external cache dir
 */
@Nullable
@TargetApi(VERSION_CODES.FROYO)
private static File getExternalCacheDir(@NonNull Context context) {
    if (Utils.hasFroyo()) {
        return context.getExternalCacheDir();
    }

    // Before Froyo we need to construct the external cache dir ourselves
    final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
    return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
}

From source file:com.boko.vimusic.cache.ImageCache.java

/**
 * Get the external app cache directory//from w  ww .j av  a  2 s . co  m
 * 
 * @param context
 *            The {@link Context} to use
 * @return The external cache directory
 */
public static final File getExternalCacheDir(final Context context) {
    return context.getExternalCacheDir();
}

From source file:com.common.library.bitmap.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use//www.java  2  s .co m
 * @return The external cache dir
 */
@TargetApi(VERSION_CODES.FROYO)
public static File getExternalCacheDir(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        return context.getExternalCacheDir();
    }

    // Before Froyo we need to construct the external cache dir ourselves
    final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
    return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
}

From source file:util.Utils.java

/**
 * ?//  www .j a  va2 s  .  c  o  m
 *
 * @return 
 */
public static String getCacheDir(Context context) {
    Log.i(TAG, "CacheDir = " + context.getExternalCacheDir());
    return context.getExternalCacheDir() + Constant.CACHE_DIR;
}

From source file:com.sughimura.samplebitmaps.util.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use/*  w  w  w.j  a va 2 s.  co  m*/
 * @return The external cache dir
 */
@TargetApi(VERSION_CODES.FROYO)
public static File getExternalCacheDir(Context context) {
    if (com.sughimura.samplebitmaps.util.Utils.hasFroyo()) {
        return context.getExternalCacheDir();
    }

    // Before Froyo we need to construct the external cache dir ourselves
    final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
    return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
}

From source file:com.androidpi.bricks.gallery.lru.cache.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use/*from  w w  w. jav a  2  s .  com*/
 * @return The external cache dir
 */
@TargetApi(VERSION_CODES.FROYO)
public static File getExternalCacheDir(Context context) {
    if (AppUtil.hasFroyo()) {
        return context.getExternalCacheDir();
    }

    // Before Froyo we need to construct the external cache dir ourselves
    final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
    return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
}

From source file:com.andrew.apollo.cache.ImageCache.java

/**
 * Get the external app cache directory/*from w w  w  .  j  a v  a2  s. com*/
 * 
 * @param context The {@link Context} to use
 * @return The external cache directory
 */
public static final File getExternalCacheDir(final Context context) {
    if (ApolloUtils.hasFroyo()) {
        final File mCacheDir = context.getExternalCacheDir();
        if (mCacheDir != null) {
            return mCacheDir;
        }
    }

    /* Before Froyo we need to construct the external cache dir ourselves */
    final String mCacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
    return new File(Environment.getExternalStorageDirectory().getPath() + mCacheDir);
}

From source file:com.ifeng.util.imagecache.ImageCache.java

/**
 * Get the external app cache directory.
 * /* w w w  . ja v a 2s  .c o  m*/
 * @param context
 *            The context to use
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
    File cacheDir = null;
    if (SdkVersionUtils.hasFroyo()) {
        cacheDir = context.getExternalCacheDir();
    }

    // Before Froyo we need to construct the external cache dir ourselves
    if (cacheDir == null) {
        cacheDir = new File(Environment.getExternalStorageDirectory().getPath() + "/ifeng/data/cache/");
    }

    return cacheDir;
}

From source file:com.tangjd.displayingbitmaps.util.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use//w  w w . java2  s  . co m
 * @return The external cache dir
 */
@TargetApi(VERSION_CODES.FROYO)
public static File getExternalCacheDir(Context context) {
    File cacheDir = null;
    if (Utils.hasFroyo()) {
        cacheDir = context.getExternalCacheDir();
    }
    if (cacheDir != null) {
        return cacheDir;
    }

    // Before Froyo we need to construct the external cache dir ourselves
    final String cacheDirPath = "/Android/data/" + context.getPackageName() + "/cache/";
    return new File(Environment.getExternalStorageDirectory().getPath() + cacheDirPath);
}

From source file:com.just.agentweb.AgentWebUtils.java

static String getDiskExternalCacheDir(Context context) {

    File mFile = context.getExternalCacheDir();
    if (Environment.MEDIA_MOUNTED.equals(EnvironmentCompat.getStorageState(mFile))) {
        return mFile.getAbsolutePath();
    }/*w  ww. j av  a  2  s . c  o m*/
    return null;
}