Android httpRequest缓存
我的应用程序多次使用HttpRequest。有没有办法避免每次都叫Rest i、 e如何维护Api请求调用的缓存。而且,在没有互联网的情况下,它也应该发挥作用Android httpRequest缓存,android,caching,Android,Caching,我的应用程序多次使用HttpRequest。有没有办法避免每次都叫Rest i、 e如何维护Api请求调用的缓存。而且,在没有互联网的情况下,它也应该发挥作用 提前感谢。Android有自己的类来缓存响应。 要打开缓存,应该调用方法。比如 HttpResponseCache.install(getCacheDir(), 10 * 1024 * 1024); //10MB cache size 当你打开连接呼叫时 connection.setUseCaches(true); 像这样的事 URL
提前感谢。Android有自己的类来缓存响应。 要打开缓存,应该调用方法。比如
HttpResponseCache.install(getCacheDir(), 10 * 1024 * 1024); //10MB cache size
当你打开连接呼叫时
connection.setUseCaches(true);
像这样的事
URL url = new URL("http://site.com/");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setUseCaches(true);
你也可以读到这篇文章截击是答案。如果你是塞尔吉·卡斯特尔萨古·穆兰,截击是最好的答案。示例代码位于