我必须做什么,Android 才能使用 GUI 删除我在 sdcard 上的缓存文件?
我在 /sdcard/Android/data/my.package.name/cache
中保存了一些数据,但 Android 告诉我我的应用有 0B 缓存数据。这是错误的!
最佳答案
您永远不应该硬连接路径——例如,上面显示的路径对于大多数 Android 设备都是不正确的,因为 /sdcard
不是外部存储所在的位置。您应该对外部缓存使用 getExternalCacheDir()
,对内部缓存使用 getCacheDir()
。
请记住,如文档所述:
There is no guarantee when these files will be deleted. Note: you should not rely on the system deleting these files for you; you should always have a reasonable maximum, such as 1 MB, for the amount of space you consume with cache files, and prune those files when exceeding that space.
(强调他们的)
关于android - 如何让android删除SD卡上的缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7791419/