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.haipeng.libraryforandroid.cacheormemory.imageload.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use// ww  w. j  av a  2  s.  c  om
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
    if (SDKVersionUtil.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.example.image.ImageCache.java

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

    // 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.roach.framework.cache.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use//  ww w  . ja v  a2s .co  m
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
    if (VersionUtils.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.andreaszeiser.bob.ImageCache.java

/**
 * Get the external app cache directory.
 * //from  w ww . j a  va2 s.  c  om
 * @param context
 *            The context to use
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
    if (UIUtils.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.tack.android.image.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use/* w  ww  .j a v  a2s .c o  m*/
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
    if (ConfigUtil.hasV08()) {
        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.fivehundredpxdemo.android.storage.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use/*from ww w .ja  v  a 2 s. c  o  m*/
 * @return The external cache dir
 */
@TargetApi(8)
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:com.fireplace.market.fads.util.ImageCache.java

/**
 * Get the external app cache directory.
 * //from  w ww. j  a va 2  s. c o  m
 * @param context
 *            The context to use
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
    if (Fireplace.IS_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:com.zhiyicx.zycx.sociax.gimgutil.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use/* w w  w .  j a v a 2 s.  com*/
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(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/";
    String path = Environment.getExternalStorageDirectory().getPath() + cacheDir;

    return new File(path);
}

From source file:com.msx7.image.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use//from   w ww. ja v  a  2  s.  co  m
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
    File file = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        file = context.getExternalCacheDir();
    }
    // Before Froyo we need to construct the external cache dir ourselves
    final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
    if (file == null) {
        file = new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
    }
    return file;

}

From source file:image_cache.ImageCache.java

/**
 * Get the external app cache directory.
 *
 * @param context The context to use/* w  w  w  .  j a v a2 s .c om*/
 * @return The external cache dir
 */
@TargetApi(8)
public static File getExternalCacheDir(Context context) {

    if (context == null) {
        return null;
    }

    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);
}