Search code examples
androidcachingpicasso

Picasso keeps using cached image


I am using Picasso as follow to load images from my server:

String urlString = Constants.API.BASE_URL + "/storage/images/products/1.png";

Picasso.with(itemView.getContext())
    .load(urlString)
    .error(R.drawable.ic_logo)
    .placeholder(R.drawable.ic_products)
    .into(mIconImageView);

However, when I change the server's image at the same location as the loaded one: "/storage/images/products/1.png"

Picasso still using the cached (old) image.

I have navigated away from my activity by preseing back then started it again. However, Picasso keep using cached image.

When I restart my application. Picasso updates its cache.

Is there away to let Picasso uses remote-first or cache-then-remote images?


Solution

  • use it first.

    this may invalidate all memory cached images for the specified uri.

    Picasso.with(itemView.getContext())
                .invalidate(urlString);
    

    call Picasso here again

    Picasso.with(itemView.getContext())
    .load(urlString)
    .error(R.drawable.ic_logo)
    .placeholder(R.drawable.ic_products)
    .into(mIconImageView);