0

I'm having this problem where I'm sending some url requests with Volley and everything is working fine, until I have to clear a single request from the Volley cache, Volley logs that the request coulnd't be find.

Here's my request:

StringRequest stringRequest = new StringRequest(method, url, responseListener, errorListener) {...};
    Log.d("Request URL", "" + url);
    stringRequest.setTag(url);
    stringRequest.setRetryPolicy(new DefaultRetryPolicy(8000, 1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    requestQueue.add(stringRequest);

And when I try to remove the cached request later I simply do:

requestQueue.getCache().remove(url);

This is the volley log:

07-03 17:01:03.259 31199-31199/my.package D/Volley: [1] DiskBasedCache.remove: Could not delete cache entry for key=http://www.myappwebsite.com/..., filename=-615250731-706907684

Any help would be really appreciated.

Lampione
  • 1,622
  • 3
  • 21
  • 39
  • Are you sure that the key that you have provided as a parameter in the remove method, matches with the one that has been saved in the cache? Can you check for an encoding issue on the URL? – Alexios Karapetsas Jul 03 '16 at 15:59
  • Hi, thank you for your reply. I've later found out that the problem was in the tag, StringRequest got his own tag which can be retrieved by getCacheTag(), this is now working. Thank you by the way! – Lampione Jul 03 '16 at 16:32

1 Answers1

1

getCache().clear() has perhaps helped in my situation.

requestQueue.getCache().clear();

Have also a look at this question, it might also enlighten you.

Note: depending on how your code is made, be sure your requestQueue is only instantiated once.

Community
  • 1
  • 1
Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137