My application is using HttpRequest for many times. is there a way to not call Rest for every time?
i.e How maintain cache for Api Request call. and it should also be worked when there is no internet
Thanks in advance.
My application is using HttpRequest for many times. is there a way to not call Rest for every time?
i.e How maintain cache for Api Request call. and it should also be worked when there is no internet
Thanks in advance.
Android have own classes to cache responses. To turn cache you should call HttpResponseCache.install method. Such as
HttpResponseCache.install(getCacheDir(), 10 * 1024 * 1024); //10MB cache size
and when you open connection call
connection.setUseCaches(true);
Somthing like this
URL url = new URL("http://site.com/");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setUseCaches(true);
Also you can read this topic