【问题标题】:okhttp3 with Retrofit where is the cached file on the phone? Unable to see it inside the Application directoryokhttp3 with Retrofit 手机上的缓存文件在哪里?在应用程序目录中看不到它
【发布时间】:2018-06-04 19:38:03
【问题描述】:

okhttp3 with Retrofit 手机上的缓存文件在哪里?在应用程序目录中看不到它,这是我的代码: 我在 Android 中发送请求,结果也很好,但它被缓存在哪里??

CACHE_SIZE_BYTES also defined 10 mb
...some code
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
builder.cache(new Cache(getApplicationContext().getCacheDir(),CACHE_SIZE_BYTES));
OkHttpClient client = builder.build().client(client);
final Retrofit retrofitlogin=new Retrofit.Builder()
.baseUrl(GlobalROOT_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
..rest of the code.

【问题讨论】:

    标签: android caching retrofit okhttp


    【解决方案1】:

    OkHttp 缓存文件不打算被其他应用程序访问,格式没有记录或被视为公共 API,并发访问可能会导致问题。

    但是如果你记录缓存目录,它会告诉你存储文件的目录

    Log.w("WARN", getApplicationContext().getCacheDir().toString())
    12-22 08:11:22.071 16936-16936/? W/WARN: /data/user/0/com.squareup.okhttptestapp/cache
    

    【讨论】:

      猜你喜欢
      • 2017-02-17
      • 2017-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-03
      • 1970-01-01
      相关资源
      最近更新 更多