OkHttpClient V2.0.0에서 더 이상 사용되지 제시 윌슨이 지적 당신이 당신의 자신의 캐시를 만들 필요가
높은.
다음 코드는 10MB 캐시를 만들어야합니다.
File httpCacheDirectory = new File(application.getApplicationContext()
.getCacheDir().getAbsolutePath(), "HttpCache");
HttpResponseCache httpResponseCache = null;
try {
httpResponseCache = new HttpResponseCache(httpCacheDirectory, 10 * 1024);
} catch (IOException e) {
Log.e(getClass().getSimpleName(), "Could not create http cache", e);
}
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setResponseCache(httpResponseCache);
builder.setClient(new OkClient(okHttpClient));
코드는 Jesse Wilsons example on Github을 기반으로합니다. OkHttpClient v2의
documentation은 내가 별도의 대답에 사용 된 코드를 추가하십시오. 당신의 예제에서 복사 한 이후 코드가 괜찮 으면 좋겠다. – Janusz
http://stackoverflow.com/questions/22445177/trying-to-make-use-of-httpcache-android는 캐시를 더 이상 구성 할 필요가 없다고 말합니다. 이 올바른지? – Janusz