okhttp3 with Retrofit手机上的缓存文件在哪里?无法在Application目录中看到它

问题描述 投票:-1回答:1

okhttp3 with Retrofit手机上的缓存文件在哪里?无法在Application目录中看到它是我的代码:我在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个回答
0
投票

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
© www.soinside.com 2019 - 2024. All rights reserved.