简体   繁体   English

保存在外部缓存中的文件在卸载时不会删除

[英]files saved in External Cache do not delete on uninstall

Here is said that files saved on getExternalCacheDir() will be deleted on uninstall. 这里说在getExternalCacheDir()上保存的文件将在卸载时删除。

I have placed my downloaded files there. 我已将下载的文件放在那里。 Everything works fine with 3 devices. 3台设备一切正常。 But with one Samsung Galaxy S2 with Android 4.0 these files do not delete. 但是有一个三星Galaxy S2与Android 4.0这些文件不删除。 What can be the reason of this? 这可能是什么原因?

Looking at the getExternalCacheDir() documentation: 查看getExternalCacheDir()文档:

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. 目前平台删除此处文件的唯一时间是在JELLY_BEAN_MR1或更高版本上运行时, Environment.isExternalStorageEmulated()返回true。 Note that you should be managing the maximum space you will use for these anyway, just like with getCacheDir() . 请注意,您应该管理将用于这些的最大空间,就像使用getCacheDir()

Looks like the device has to be Android 4.2 and later for the external storage caching. 看起来该设备必须是Android 4.2及更高版本才能进行外部存储缓存。 You could have your app do its own clean up. 您可以让自己的应用程序自行清理。 See here for detecting when your app is about to be uninstalled. 请参阅此处以了解何时即将卸载您的应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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