问题描述
怎么可能是 context.getApplicationContext()。getCacheDir()
返回空
?据我所知内部缓存目录应该一直存在。
how is it possible that context.getApplicationContext().getCacheDir()
returns null
? As far as I know the internal cache directory should always exist.
谢谢!
推荐答案
也许是因为你没有足够的内部存储返回null?尝试同时使用 getExternalCacheDir
maybe it returns null since you don't have enough internal storage? try to also use getExternalCacheDir
另外,如果它不工作,只需访问路径。
also , if it doesn't work , simply go to the path.
标准是,它应该给你的路径/数据/数据/ YOUR_APP_PACKAGE_NAME /缓存/,如果你想在外部存储高速缓存,它应该给你的路EXTERNAL_STORAGE_PATH /安卓/数据/ YOUR_APP_PACKAGE_NAME /缓存/。
the standard is that it should give you the path "/data/data/YOUR_APP_PACKAGE_NAME/cache/" , and if you want the external storage cache , it should give you the path "EXTERNAL_STORAGE_PATH/Android/data/YOUR_APP_PACKAGE_NAME/cache/" .
这篇关于缓存目录不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!