Android examples for android.os:Environment
get Cache Path
import java.io.File; import android.content.Context; import android.os.Environment; public class Main { public static File getCachePath(Context context, String uniqueName) { String cachePath;//ww w . j a va 2 s . co m if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) { cachePath = context.getExternalCacheDir().getPath(); } else { cachePath = context.getCacheDir().getPath(); } return new File(cachePath + File.separator + uniqueName); } }