How do I clean the cache of an Android application by code?

1

I am developing an android application on a catalog, the images I load with Glide, but there is a problem, and that is that the images can be updated from an admin of a web page, and when I updated it in the application, it follows me appearing the previous image.

Clean the cache memory of the application and if you updated the image, but I would like to know how to delete the chace by code, I hope your answers on how to do it, or another solution how to refresh the http images in Glide.

    
asked by Juan L. Antón Santamaria 29.01.2018 в 18:43
source

2 answers

0

Using Glide you can avoid caching by using the property, skipMemoryCache(true) :

Glide.with(Contexto).load(urlImagen).skipMemoryCache(true).into(imageView);

What this property does is disable the cache.

Also using Glide , you can avoid caching on images by adding a different signature each time you upload the image using the class UUID :

Glide.with(Contexto).load(urlImagen).signature(new StringSignature(UUID.randomUUID().toString())).into(imageView);
    
answered by 29.01.2018 / 22:40
source
0

According to a issue on your github , when you load the image you have to specify the asignature always with values different to avoid that you cachee the image as for example the last date of update of profile or the current date as milliseconds:

Glide.with(ActividadActualOContexto.this)
     .load(urlImagen)
     .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
     .into(referenciaImageView);
    
answered by 29.01.2018 в 18:57