Ive followed a few tutorials, one in particular shows to do the following if you want to use the cached result for HTTP call.
Cache cache = MyApplication.getInstance().getRequestQueue().getCache();
Cache.Entry entry = cache.get(url);
if (entry != null) {
// means there is a cached result, to use it we have to do something like this...
new JSONObject(new String(entry.data, "UTF-8"))
} else {
// no cached result found so make the full request
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
//stuff
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//stuff
}
});
// Adding request to request queue
MyApplication.getInstance().addToRequestQueue(jsonObjReq, TAG);}
I was under the impression that the default behaviour was to cache the result, and retrieve the cached result automatically, without having the explicitly get the cached entry - ie. entry = cache.get(url)..
so im basically asking whether or not this is the default behaviour.
thanks