Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diff between getExternalCacheDir vs getExternalFilesDir in android

I read the docs but I can't seem to figure out what the difference is. Is it something subtle that does not really matter? I want to create a cache of ten files. So when I went to use getExternalFilesDir, I noticed there is a getExternalCacheDir. So now I am confuse as to which one I should use (the name does not always tell the whole story). So can anyone put the difference in layman terms for me? thanks.

like image 960
learner Avatar asked Nov 14 '13 14:11

learner


People also ask

What is app specific storage?

App-specific storage: Store files that are meant for your app's use only, either in dedicated directories within an internal storage volume or different dedicated directories within external storage. Use the directories within internal storage to save sensitive information that other apps shouldn't access.

What is cache directory in Android?

Your Android phone's limited storage can fill up quickly. And one cause of this that's easy to overlook is the stored information that apps regularly create to run at their best. These temporary data files are known as a cache; a fair chunk of your Android phone's storage space might be filled up with cache files.


2 Answers

The ExternalFilesDir is not a cache, it will save your files, and they will remain there until the app is removed or the files manually whereas the cachedir will empty when needed

like image 163
Pontus Backlund Avatar answered Oct 09 '22 23:10

Pontus Backlund


I'm a newbie to Android but would like to help you with the below link. The below article explores all possible ways / methods to use under different scenarios. It helped me in improving my understanding and hope the same with you and others as well

http://www.grokkingandroid.com/how-to-correctly-store-app-specific-files-in-android/

like image 26
Ramakishna Balla Avatar answered Oct 09 '22 23:10

Ramakishna Balla