缓存目录不存在不存在、缓存、目录

2023-09-06 03:18:19 作者:正在減肥的吃貨

怎么可能是 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_STORAG​​E_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/" .