0

How to inform the app that an image that was already downloaded and cached, was updated/changed on the server and needs to be Re-downloaded?

I have a ListView on my app that downloads the images and caches them so they wont have to be loaded again and again.

The problem is that when I edit or change the image on the server, the image on the app stays the same, because it is cached. it uses the image URL.

In other words, the code checks whether that URL was already used to download that image, and if it does, he pulls it out of the cache and displays it. else - it downloads it.

How can I inform the app, that there is a new image?

I mean, is there any common way to do that in my situation?

Cœur
  • 37,241
  • 25
  • 195
  • 267
mn6vdv23g
  • 734
  • 2
  • 10
  • 33

1 Answers1

1

You can add a "Re-download" button, or something similar, that re-downloads the image and replaces the old one, it's the easiest way.

Another thing you can do, is check online every time if images are correct (you can have a value "version" that checks if images are current version), if an image is older version, download a new one.

I prefer the first version, it's way easier, but it's your pick :)

TomTsagk
  • 1,474
  • 9
  • 23
  • I think I should use the second one.. its a listview with many items and the users wont have to refresh every single image.. But, are there any other ways? – mn6vdv23g Dec 07 '13 at 18:49
  • I can't think of any other way, if you tell me more details about the app you are making maybe I could help more, like are you upgrading all images? or some images at a time ? – TomTsagk Dec 07 '13 at 19:06
  • There are many values. every value has an image. every user can edit his own value's image. those values are always shown to all of the other users. so, the image is updated one at a time, by the user. (of course there can be a situation when a few users update their images at the same time). – mn6vdv23g Dec 07 '13 at 19:10
  • so you mean users can change the image themselves? like a profile picture or something like that ? In this case I guess the only thing you can do is that if there is wi-fi available, download images again, else use cache – TomTsagk Dec 07 '13 at 20:35
  • Yeah. you could say that. So basically re-download the images every time the user enters the listview? It doesnt really make sense.. How do they do that.. lets say... on instagram? – mn6vdv23g Dec 07 '13 at 21:57
  • I'm not sure about instagram, but "facebook messenger" (I think it's unofficial app) works like that, pictures all are cached, and when you enter the app it checks once only for wi-fi, if it's available it re-downloads images, I don't know how often you open your listView my advice is to do that each time user runs your app (inside the onCreate maybe?) – TomTsagk Dec 07 '13 at 22:11