【问题标题】:Creating directory for OkHttp cache on Android?在 Android 上为 OkHttp 缓存创建目录?
【发布时间】:2015-12-21 12:19:33
【问题描述】:

在 Android 上,我应该如何为 com.squareup.okhttp.Cache 构造函数创建 File 参数? Context 似乎给了你很多选择:

  • new File(context.getCacheDir(), "HttpResponseCache")
  • new File(context.getExternalCacheDir(), "HttpResponseCache")
  • context.getDir("HttpResponseCache", Context.MODE_PRIVATE)

只是想知道最佳实践是什么。谢谢!

【问题讨论】:

    标签: android caching okhttp


    【解决方案1】:

    第一个应该可以很好地工作,并为您的用户提供释放磁盘空间的机制是必要的。

    【讨论】:

      猜你喜欢
      • 2019-08-09
      • 2020-02-09
      • 2013-11-07
      • 2017-05-07
      • 2017-03-09
      • 2015-01-02
      • 2016-01-29
      • 2016-10-25
      • 1970-01-01
      相关资源
      最近更新 更多