Nitesh Khatri Nitesh Khatri - 20 days ago 10
Android Question

Remove image from cache in Glide library

I am using Glide in one of my projects to show image from file.

Below is my code how I am showing the image:

.load(Uri.parse("file://" + imagePath))

The image at this location(
) keeps on changing. By default Glide cache the image it shows in the
. Because of this, the Glide was showing the first image from cache for new images at that location.

If I change the image at location
with some other image having same name then the Glide is showing the first image instead of new one.

Two queries are:

  1. Is it possible to always the image from File and not cache? This way problem will be solved.

  2. Is it possible to clear image from cache before getting newly replaced image? This will also solve the problem.


This is how I solved this problem.

    .load(Uri.parse("file://" + imagePath))

diskCacheStrategy() can be used to handle the disk cache and you can skip the memory cache using skipMemoryCache() method.