在 Android 上为 OkHttp 缓存创建目录?
Creating directory for OkHttp cache on Android?
在 Android 上,我应该如何为 com.squareup.okhttp.Cache
构造函数创建 File
参数? Context
似乎给了你很多选择:
new File(context.getCacheDir(), "HttpResponseCache")
new File(context.getExternalCacheDir(), "HttpResponseCache")
context.getDir("HttpResponseCache", Context.MODE_PRIVATE)
只是想知道最佳做法是什么。谢谢!
第一个应该运行良好,并为您的用户提供释放磁盘的机制 space 是必要的。
在 Android 上,我应该如何为 com.squareup.okhttp.Cache
构造函数创建 File
参数? Context
似乎给了你很多选择:
new File(context.getCacheDir(), "HttpResponseCache")
new File(context.getExternalCacheDir(), "HttpResponseCache")
context.getDir("HttpResponseCache", Context.MODE_PRIVATE)
只是想知道最佳做法是什么。谢谢!
第一个应该运行良好,并为您的用户提供释放磁盘的机制 space 是必要的。