Picasso is a pretty cool image downloading and caching library for Android. Not only does it manage download and cache , it even allows you to manipulate the image by allowing basic transformations like rotate, resize, center, crop etc
In one of our recent implementations we needed to purge the cache and reset the image Picasso was caching . We faced some inconsistent behavior here. Even after using Picasso.with(getActivity()).invalidate(targetUrl); and setting a new image at the same Url . The same old image would show up. Also this would happen intermittently pointing to a timing issue ( Maybe we were loading it again before the cache could get purged…)
The following code piece finally ensure we load from the network in this specific case but also save to the cache for all future loads
Hope this helps some other Image lovers out there!!