Updating the Android Ion cache

I am using a specific URL to get an image on the web, but the URL itself changes automatically every few minutes. I am using the ION library from Here The problem I am running into is when I refresh the page, the page itself looks like it is refreshing, but the same image appears. I am assuming this is a cached image? If I reinstall the app, it gets the correct image again.

This is how I use ION where imageID2 [position] is just a typical url for a jpg.

    Ion.with(imageView)
            .placeholder(R.drawable.ic_launcher)
            .error(R.drawable.ic_launcher)
            .load(imageId2[position]);

      

Is there anyway I can disable the cache or just force it to redraw images again?

+3


source to share


3 answers


You can add a unique string to your URL, such as the current timestamp, to force Ion to treat each request as unique.



+3


source


Use .noCache () to traverse caches.



+6


source


As per the documentation here , use the "long" way to create an ImageView request so you can add headers, noCache, etc.

Modify your original query:

Ion.with(imageView)
        .placeholder(R.drawable.ic_launcher)
        .error(R.drawable.ic_launcher)
        .load(urlString);

      

For this:

Ion.with(context)
        .load(urlString)
        .noCache()
        .withBitmap()
        .placeholder(R.drawable.ic_launcher)
        .error(R.drawable.ic_launcher)
        .intoImageView(imageView);

      

+5


source







All Articles