Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.os.Environment; import java.io.File; public class Main { public static String getAppCachePath(Context context) { String cachePath; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) { File externalCacheDir = context.getExternalCacheDir(); // context.getExternalCacheDir() maybe null if (externalCacheDir == null) { cachePath = context.getCacheDir().getPath(); } else { cachePath = externalCacheDir.getPath(); } } else { cachePath = context.getCacheDir().getPath(); } return cachePath; } }