Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getFilesDir() vs getCacheDir()

In Android you can use getFilesDir() to get a path to your internal /files/ folder, whereas getCacheDir() gets you a path to your internal /cache/ folder.

Is the only functional difference between these two folders the fact that Android may auto-clear some files in the cache directory if needed?

I am trying to understand the kinds of situations in which it would be a good idea to use the cache folder.

like image 253
KaliMa Avatar asked Apr 10 '26 21:04

KaliMa


1 Answers

getFilesDir() >> It is used for permanent storage directory.

getCacheDir() >> Returns application specific cache directory on the file system. The system could automatically delete files in this directory in some cases such as when memory is almost full.

like image 90
thelearner Avatar answered Apr 13 '26 12:04

thelearner