问题
1)The default implementation of the disc based cache present in android -volley is allocated a total memory of 5MB .
2)But the app Iam developing contains a lot of images .So I want to increase the size of the memory allocated by disc based cache .
3)So I want to increase the size of the cache ..I can simple do it by changing the value of DEFAULT_DISK_USAGE_BYTES inside Diskbasedcache.java file .
4)But I want to allocate memory based on the amount of space available in the disc ???Is there any way to implement it ??
回答1:
Few thoughts about Volley cache:
Using a disk based L1 cache may cause i/o blocking issues. Volley already has an implicit disk L2 cache. BitmapLruImageCache is a basic "least recently used" in memory cache implementation. It is fast and does not block I/O. This is the recommended approach.
I recommend you to play around this L1 cache for Volley
for tweaking the size have a look at this:
RequestQueue volleyQueue = Volley.newRequestQueue(this);
DiskBasedCache cache = new DiskBasedCache(getCacheDir(), 16 * 1024 * 1024);
volleyQueue = new RequestQueue(cache, new BasicNetwork(new HurlStack()));
volleyQueue.start();
Ref: Volley cache other ref about volley cache http://www.jayway.com/2013/10/04/image-caching-with-volley/
来源:https://stackoverflow.com/questions/21298692/what-is-the-best-way-to-fix-the-size-of-the-disc-based-cache-android-volley