0

The user can upload an image and I want to display the image in a listview. This is the code so far:

final String urlForImage = baseUrlForImage + jsonObject.get("imageName");
new DownloadImageTask(cell.imageViewCustomer).execute(urlForImage);
final DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true)
    .cacheOnDisc(true).resetViewBeforeLoading(true)
    .showImageForEmptyUri(cell.imageViewCustomer.getDrawable())
    .showImageOnFail(cell.imageViewCustomer.getDrawable())
    .showImageOnLoading(cell.imageViewCustomer.getDrawable()).build();
imageLoader.displayImage(urlForImage, cell.imageViewCustomer, options);

But now if the user uploads a new image, the older one from the cache will be loaded in the listview and the new image will be loaded every time from the internet.

How can I override the old image from the user, if the user uploads a new image?

Stephane Mathis
  • 6,542
  • 6
  • 43
  • 69
FabASP
  • 581
  • 1
  • 6
  • 20

2 Answers2

0

This could help you. Cleaning the cache (or a part of) sounds like a good way.

Community
  • 1
  • 1
arnaud.b
  • 66
  • 1
  • 8
0

An easy solution is to change the url of the image, just add ?v=1 at the end and increment the number each time the user changes the image.

Stephane Mathis
  • 6,542
  • 6
  • 43
  • 69