I'm creating an application which is going to download image from specific url and display it on ImageView. Server changes this image over time, but url stays the same. So I want to implement such logic:
- When app is rotated or reopened, load image from apps cache
- When user clicks the download button, image should be re-downloaded from the network and replace the cache
How do I implement such approach with Picasso? Or maybe some other library would fit it better?
Picasso.with(context)
.load(url)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.networkPolicy(NetworkPolicy.NO_CACHE)
.fit()
.centerCrop()
.into(imageView);
Each NO_CACHE
skips the cache on the way down to load the resource. The cached version will be updated by the new content.
来源:https://stackoverflow.com/questions/29144150/force-re-downloading-image-with-picasso