Reference

getExternalCacheDir()

getExternalCacheDir() returns an app-private cache directory on external (shared) storage. It needs no permission, counts as the app's cache in Settings, and is deleted on uninstall, but the OS does not guarantee auto-eviction of it under low storage.

Android developmentAndroid

getExternalCacheDir()

Also known as: android getexternalcachedir, external cache dir, app external cache, Context.getExternalCacheDir

getExternalCacheDir() returns an app-private cache directory on external (shared) storage. It needs no permission, counts as the app's cache in Settings, and is deleted on uninstall, but the OS does not guarantee auto-eviction of it under low storage.

  • Lives at /sdcard/Android/data/<package>/cache and needs no permission since KitKat.
  • The OS does not guarantee auto-eviction of it under low storage.
  • It can return null when external storage is unmounted, and is wiped on uninstall.

What getExternalCacheDir() returns

Context.getExternalCacheDir() returns a File under the app-specific external directory, typically /sdcard/Android/data/<package>/cache (formally /storage/emulated/0/Android/data/<package>/cache). Despite the name, on most modern devices this is part of the same internal flash exposed as the primary external volume, not a removable SD card.

Since Android 4.4 (KitKat), apps no longer need WRITE_EXTERNAL_STORAGE to write to their own app-specific external directory, and under scoped storage this directory stays directly accessible without MediaStore or the Storage Access Framework. The folder is removed automatically when the app is uninstalled.

External cache vs internal cache

Use getExternalCacheDir() for larger caches such as downloaded media, video thumbnails, or offline blobs that would bloat limited internal space. Use getCacheDir() for small, frequently accessed scratch data. A device can also expose multiple app-specific external roots via getExternalCacheDirs() (for example a secondary SD volume).

A key difference: the system does not promise to automatically purge getExternalCacheDir() when storage is low the way it does for the internal cache, and the returned value can be null if external storage is unmounted. Apps should call Environment.getExternalStorageState(), prune old files themselves, and tolerate the directory being unavailable.

Why it matters for a storage cleaner

External cache is often where the largest reclaimable app data hides, since media-heavy apps stash downloads here. A cleaner like Cleanor surfaces this space as part of the app's clearable cache and removes it on the user's request, freeing room without deleting saved photos or documents.

Both getCacheDir() and getExternalCacheDir() are wiped together by the system's Clear cache action, so a cleaner that targets cache totals is accounting for both directories.

Related terms

Keep reading the reference.

Act on it

Guides and tools for this topic.