Some more details inline (received Ficus' response while I was typing this :-)).
> Perhaps I've misunderstood how the ImageLoader class works but based on the
> Google I/O session (and a brief look through the code) I was under the
> impression that images are cached by a caching class which implements the
> ImageCache interface. Is this correct?
>
> Or is image caching handled by the underlying RequestQueue and all image
> requests are cached to disk anyway as long as the RequestQueue has a disk
> cache assigned to it?
This is correct. All HTTP responses, including images, are
automatically cached by Volley if the cache headers allow for it.
The cache in ImageLoader serves a different purpose: It keeps bitmaps
in RAM such that you can populate the UI without:
1. A round-trip to the network or disk
2. Image decoding
This allows for flicker-free, synchronous UI population from the UI
thread (if the image is in cache), with a fallback to disk cache or
network when necessary.
> I've been trying to clarify this point for a bit now but so far haven't
> gotten a satisfactory response :)
>
> My basic need here is to cache images for a list of articles so that: a) the
> user has access to those images even if they are offline b) the article list
> loads fast the second time they access it since most of the images would
> have been cached. So far have not had a great deal of success with
> NetworkIMageView to do this consistently. If I use a basic LruCache as
> mentioned in the Google I/O session, the images load sometimes and sometimes
> they don't and they are always fetched again from the server if needed.
> There appears to be no caching of the images.
You can't use Volley for offline-access, that's not what it's designed
for. Its caches aren't offline storage, entries can be evicted at any
time.
If you see a lot of cache misses, check that:
1. The images are in fact cacheable, i.e. the server responds with
appropriate HTTP cache headers.
2. You have a unique URL for images.
3. The disk cache of your RequestQueue has a large enough disk quota.
Enabling VERBOSE logging for Volley should help you see what's going
on. With a device / emulator connected:
'adb shell setprop log.tag.Volley VERBOSE'
Then run through the app and watch logcat for Volley messages.
Christoph