List of usage examples for android.content Context getCacheDir
public abstract File getCacheDir();
From source file:Main.java
public static void clearAppCache(final Context context, final Handler handler) { new Thread(new Runnable() { @Override/*from w w w . j a v a2s . c o m*/ public void run() { File cacheDir = new File(context.getCacheDir().getPath(), DEFAULT_CACHE_DIR); clearCacheFolder(cacheDir, System.currentTimeMillis()); handler.sendEmptyMessage(1); } }).start(); }
From source file:Main.java
public static final File getDownloadDir(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { return new File(context.getExternalCacheDir(), DOWNLOAD_DIR); }//from w w w .j a v a 2 s. c o m return new File(context.getCacheDir(), DOWNLOAD_DIR); }
From source file:Main.java
public static String getDiskCacheDir(Context context, String dirName) { final String cachePath = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ? context.getExternalCacheDir().getPath() : context.getCacheDir().getPath(); return cachePath + File.separator + dirName; }
From source file:com.android.contacts.util.ContactPhotoUtils.java
private static String pathForTempPhoto(Context context, String fileName) { final File dir = context.getCacheDir(); dir.mkdirs();/*from w w w.j a v a 2 s . com*/ final File f = new File(dir, fileName); return f.getAbsolutePath(); }
From source file:Main.java
public static String getCachePath(final Context context) { if (true)//from w ww . j av a2s . c o m return "/sdcard/"; if (context.getExternalCacheDir() != null) { return context.getExternalCacheDir() + "/"; } else { return context.getCacheDir().getAbsolutePath() + "/"; } }
From source file:Main.java
public static String getCacheDir(Context ctx) { return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable() ? ctx.getExternalCacheDir().getPath() : ctx.getCacheDir().getPath(); }
From source file:Main.java
private static File getTempFile(Context context) { File file = null;/* w ww. ja v a 2 s. c o m*/ try { String fileName = "IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); file = File.createTempFile(fileName, ".jpg", context.getCacheDir()); } catch (IOException e) { } return file; }
From source file:Main.java
private static File getTempFile(Context context) { File file = null;//from w ww .j a v a 2s . co m try { String fileName = "IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); file = File.createTempFile(fileName, ".jpg", context.getCacheDir()); } catch (IOException e) { e.printStackTrace(); } return file; }
From source file:Main.java
public static void setCacheRoot(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { mCacheRoot = Environment.getExternalStorageDirectory().getPath() + "/"; } else {//from w ww . j a v a2 s .c o m mCacheRoot = context.getCacheDir().getPath() + "/"; } }
From source file:org.mythtv.client.MainApplication.java
private static void initImageLoader(Context context) { File cacheDir = new File(context.getCacheDir(), "images"); if (!cacheDir.exists()) { cacheDir.mkdir();// w ww .j av a 2 s . co m } // This configuration tuning is custom. You can tune every option, you may tune some of them, // or you can create default configuration by // ImageLoaderConfiguration.createDefault(this); // method. ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(5) .threadPriority(Thread.MIN_PRIORITY + 3).denyCacheImageMultipleSizesInMemory() .memoryCache(new WeakMemoryCache()).discCache(new UnlimitedDiscCache(cacheDir)).build(); // Initialize ImageLoader with configuration. ImageLoader.getInstance().init(config); L.disableLogging(); }