List of usage examples for android.content Context getCacheDir
public abstract File getCacheDir();
From source file:at.diamonddogs.util.Utils.java
/** * Get available cache directory// w ww.j a va2 s . c om * * @param context a {@link Context} * @return a {@link File} pointing to a the external or internal cache * directory */ public static File getCacheDir(Context context) { File path = context.getExternalCacheDir(); if (path == null) { path = context.getCacheDir(); } return path; }
From source file:com.fsck.k9.helper.Utility.java
public static void clearTemporaryAttachmentsCache(Context context) { File cacheDir = context.getCacheDir(); File tempAttachmentsDirectory = new File(cacheDir.getPath() + RESIZED_ATTACHMENTS_TEMPORARY_DIRECTORY); if (tempAttachmentsDirectory.exists()) { try {/*from w w w .j ava 2 s . c om*/ FileUtils.cleanDirectory(tempAttachmentsDirectory); } catch (IOException e) { Timber.e(e, "Error occurred while cleaning temporary directory for resized attachments"); } } }
From source file:app.utils.ACache.java
public static ACache get(Context ctx) { File f = new File(ctx.getCacheDir(), "ACache"); return get(f, MAX_SIZE, MAX_COUNT); }
From source file:com.microsoft.mimickeralarm.ringing.ShareFragment.java
public static Uri saveShareableBitmap(Context context, Bitmap bitmap, String question) { drawStamp(context, bitmap, question); File tempFile;/* w w w. jav a2s . com*/ try { tempFile = File.createTempFile("mimicker", ".jpg", context.getCacheDir()); tempFile.setReadable(true, false); tempFile.deleteOnExit(); } catch (IOException ex) { Logger.trackException(ex); return null; } if (tempFile.canWrite()) { try { FileOutputStream stream = new FileOutputStream(tempFile); bitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream); stream.close(); } catch (IOException ex) { Logger.trackException(ex); return null; } } return Uri.fromFile(tempFile); }
From source file:com.hippo.ehviewer.EhApplication.java
@NonNull public static SimpleDiskCache getSpiderInfoCache(@NonNull Context context) { EhApplication application = ((EhApplication) context.getApplicationContext()); if (null == application.mSpiderInfoCache) { application.mSpiderInfoCache = new SimpleDiskCache(new File(context.getCacheDir(), "spider_info"), 5 * 1024 * 1024); // 5M }//from ww w. j a va 2 s . c om return application.mSpiderInfoCache; }
From source file:com.fsck.k9.helper.Utility.java
public static String getResizedImageFile(Context context, Uri uri, float multiplier) { File cacheDir = context.getCacheDir(); File tempAttachmentsDirectory = new File(cacheDir.getPath() + RESIZED_ATTACHMENTS_TEMPORARY_DIRECTORY); tempAttachmentsDirectory.mkdirs();// w w w. java 2s .c o m File tempFile = null; Bitmap bitmap = null; Bitmap resized = null; FileOutputStream out = null; try { tempFile = File.createTempFile("TempResizedAttachment", null, tempAttachmentsDirectory); bitmap = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri); resized = Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * multiplier), (int) (bitmap.getHeight() * multiplier), true); out = new FileOutputStream(tempFile); resized.compress(Bitmap.CompressFormat.PNG, 100, out); } catch (IOException e) { Timber.e(e, "Error while resizing image attachment"); return ""; } finally { IOUtils.closeQuietly(out); } return tempFile.getAbsolutePath(); }
From source file:app.utils.ACache.java
public static ACache get(Context ctx, int max_zise, int max_count) { File f = new File(ctx.getCacheDir(), "ACache"); return get(f, max_zise, max_count); }
From source file:org.lol.reddit.common.General.java
public static File getBestCacheDir(final Context context) { final File externalCacheDir = context.getExternalCacheDir(); if (externalCacheDir != null) { return externalCacheDir; }/*from ww w. java 2s.c o m*/ return context.getCacheDir(); }
From source file:org.kontalk.util.MediaStorage.java
public static File getInternalMediaFile(Context context, String filename) { return new File(context.getCacheDir(), filename); }
From source file:com.ryan.ryanreader.common.General.java
/** * // ww w.j a va2 s . co m * * @param context * @return */ public static File getBestCacheDir(final Context context) { // SD final File externalCacheDir = context.getExternalCacheDir(); if (externalCacheDir != null) { return externalCacheDir; } return context.getCacheDir(); }