0

I'm using Picasso to load image into my ImageView like this :

Picasso.with(getContext())
       .load(store.getString("profile"))
       .placeholder(R.drawable.ic_nothumb)
       .resize(120, 120)
       .into(iv);

Where store.getString("profile") = a string representing my url.

However even if the path don't change, when I update the image within the same path, Picasso still loading the previous image.

I've read that we can clear the network cache but I can't find a way to use .invalidate() method nor .cachePolicy() or .networkPolicy() when I try to use them I have unresolved symbol.

EDIT: I updated my Picasso version to compile

"com.squareup.picasso:picasso:2.5.2"

And now I can use .networkPolicy(), however I got this error I can't find any solution to fix it :

E/AndroidRuntime: FATAL EXCEPTION: main Process: dev.com.diaginfo, PID: 10614 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/picasso/NetworkPolicy; Caused by: java.lang.ClassNotFoundException: Didn't find class "com.squareup.picasso.NetworkPolicy" on path: DexPathList

Milad Yarmohammadi
  • 1,253
  • 2
  • 22
  • 37
Hugo Houyez
  • 470
  • 3
  • 19
  • Check this post http://stackoverflow.com/questions/22016382/invalidate-cache-in-picasso – an_droid_dev Aug 24 '16 at 10:41
  • "i've read that we can clear the network cache but i cant find a way to use .invalidate() method nor .cachePolicy() or .networkPolicy() when i try to use them i have Unresolved Symbol." – Hugo Houyez Aug 24 '16 at 10:45
  • The new error you're facing is probably caused by going over the dex limit. However, it's a completely different case and should be posted in a new question. – manabreak Aug 25 '16 at 05:10

2 Answers2

1

You have to tell Picasso explicitly not to cache the image:

Picasso.with(getContext())
    .load(store.getString("profile"))
    .placeholder(R.drawable.ic_nothumb)
    .resize(120, 120)
    .networkPolicy(NetworkPolicy.NO_CACHE)
    .into(iv);
manabreak
  • 5,415
  • 7
  • 39
  • 96
0

Picaso use ur url as key for caching. when updating the image use a time stamp to over come this. I have used and it worked like a charm

Dinu
  • 600
  • 3
  • 6
  • 27