malhobayyeb
malhobayyeb

Reputation: 2883

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?

Upvotes: 0

Views: 1681

Answers (2)

Mithun Sarker
Mithun Sarker

Reputation: 4023

Try the following

Picasso.with(itemView.getContext())
    .load(urlString)
    .error(R.drawable.ic_logo)
    .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
    .networkPolicy(NetworkPolicy.NO_CACHE)
    .placeholder(R.drawable.ic_products)
    .into(mIconImageView);

Upvotes: 1

Dhiren Basra
Dhiren Basra

Reputation: 860

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);

Upvotes: 3

Related Questions