SlowAndSteady SlowAndSteady - 3 months ago 7
Android Question

How does getExternalCacheDir() work on Android?

From what I understand, we cache the frequently accessed objects in a memory segment that is more easily accessible than normal disk reads.

getExternalCacheDir()
, as opposed to
getCacheDir()
points to the external filesystem - which seems to me as a normal
getExternalFilesDir()
.

How does Android optimize access to ExternalCacheDir? Is it something like the "swap" space on Linux?

Answer

getExternalCacheDir() and getExternalFilesDir() are two different directories.

The difference is that the first one is intended only for temporary files or cache files that could be deleted by the system or the user (through the Settings corresponding button) to regain space.

The second one is intended for permanent files. Anyway, you have to take into account the considerations of the documentation regarding the directory returned by getExternalCacheDir().