This is pretty easy with volley as caching is build in. All you need is to call getCache with url of the request. Of course keep in mind that server is responsible to set max age of the cache and if time was passed cache is cleared
For example try this:
if(queue.getCache().get(url)!=null){
//response exists
String cachedResponse = new String(queue.getCache().get(url).data);
}else{
//no response
queue.add(stringRequest);
}
For caching is great to use VolleyExtended: eu.the4thfloor.volleyextended There is updated Response listener, where you get additional boolean changed which means if response is different to last response in cache. And on error response there is additional parameter response (cached) which you can use in case of server or network outtage. Of course if it is cached only.
private class ResponseListenerYYY extends Api.ResponseListener {
@Override
public void onResponse(String response, boolean changed) {
}
@Override
public void onErrorResponse(VolleyError error, String response) {
}
}