简体   繁体   中英

files saved in External Cache do not delete on uninstall

Here is said that files saved on getExternalCacheDir() will be deleted on uninstall.

I have placed my downloaded files there. Everything works fine with 3 devices. But with one Samsung Galaxy S2 with Android 4.0 these files do not delete. What can be the reason of this?

Looking at the getExternalCacheDir() documentation:

The platform does not always monitor the space available in external storage, and thus may not automatically delete these files. Currently the only time files here will be deleted by the platform is when running on JELLY_BEAN_MR1 or later and Environment.isExternalStorageEmulated() returns true. Note that you should be managing the maximum space you will use for these anyway, just like with getCacheDir() .

Looks like the device has to be Android 4.2 and later for the external storage caching. You could have your app do its own clean up. See here for detecting when your app is about to be uninstalled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM