0

i need to show to user his profile image that i load from google cloud storage, the problem is that when i change the picture an upload it to the server, and i refresh the page i still see the old image. I tried with the ios version of the app and it instantly refreshed so it's not a problem with the server.

To load the image i use Picasso and i do like this:

Picasso.with(ProfileActivity.this).load(imageURL).memoryPolicy(MemoryPolicy.NO_CACHE).into(profilePhoto);

I noticed that when i uninstall the app and then install it again it refresh the image so i guess it's a problem with caching. Can anyone help? Thank you.

0

2 Answers 2

0

Before loading the image try invalidating it:

Picasso.with(ProfileActivity.this).invalidate(imageURL);
Picasso.with(ProfileActivity.this).load(imageURL).memoryPolicy(MemoryPolicy.NO_CACHE).into(profilePhoto);

EDIT: Have you tried:

Picasso  
    .with(ProfileActivity.this)
    .load(imageURL)
    .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
    .into(profilePhoto);

Acutally I think the issue is since you are not using a local image, its using the network to cache it.

If the above doesn't work try this:

Picasso  
    .with(ProfileActivity.this)
    .load(imageURL)
    .networkPolicy(NetworkPolicy.NO_CACHE)
    .into(profilePhoto);
1
  • Hi @Derek Baxter thank you it was the networkPolicy, now it work.
    – Muni
    Commented Apr 7, 2017 at 21:57
0

i figured out how to solve this. I had to add the networkPolicy like this:

Picasso.with(ProfileActivity.this)
    .load(imageURL)
    .networkPolicy(NetworkPolicy.NO_CACHE)
    .memoryPolicy(MemoryPolicy.NO_CACHE)
    .into(profilePhoto);

Now it works, thank you all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.