0

I am using volley for parsing json data, while searching i come across how to avoid redundant data form URL, does volley has inbuilt function to do like that or we have to do explicitly like below any help?

requestQueue.getCache().invalidate(url,true);
requestQueue.add(jsonObjectRequest);
Subhash Pandey
  • 111
  • 1
  • 6

1 Answers1

1

please go through this thread: caching using volley Here he is caching the data

Here is some code of caching after getting response:

 Cache.Entry cacheEntry = HttpHeaderParser.parseCacheHeaders(response);
            if (cacheEntry == null) {
                cacheEntry = new Cache.Entry();
            }
            final long cacheHitButRefreshed = 3 * 60 * 1000; // in 3 minutes cache will be hit, but also refreshed on background
            final long cacheExpired = 24 * 60 * 60 * 1000; // in 24 hours this cache entry expires completely
            long now = System.currentTimeMillis();
            final long softExpire = now + cacheHitButRefreshed;
            final long ttl = now + cacheExpired;
            cacheEntry.data = response.data;
            cacheEntry.softTtl = softExpire;
            cacheEntry.ttl = ttl;
Qandil Tariq
  • 539
  • 1
  • 3
  • 15