0

I am using square picasso library to download some images from one of our servers and load it in a list view. In my Android application I have a feature to change that downloaded image from app side and upload it to server.

I do know how to load the image from URL because it is well documented. What I need is to change/delete a particular cached item and replace it with my new image from Android application side.

Please help me. Thanks in Advance....!

Tushar Patil
  • 336
  • 4
  • 22
  • Check my ans here : http://stackoverflow.com/questions/19310985/android-universal-image-loader-show-custom-marker-with-image-in-google-map/19311091#19311091 – Haresh Chhelana Oct 11 '14 at 06:08
  • Hi Haresh is there any way to clear cache for single page. – Tushar Patil Oct 11 '14 at 06:19
  • Check out this thread here, that includes answers for both removing a particular file of the cache as well as to clear the entire cache: http://stackoverflow.com/questions/22016382/invalidate-cache-in-picasso – immichs Jun 07 '15 at 21:38

1 Answers1

0

Suppose you have a List which stores your images, used by your ListView. You assign an Adapter to your ListView which fills ListView from the List.

This is how you can replace an old (cached item) by the new one and release space for the old one:

public void replaceListItem (List<Bitmap> list,  int position, Bitmap newBitmap) {
     Bitmap oldBitmap = list.set(position, newBitmap);
     if (oldBitmap != null)
          oldBitmap.recycle();  // This will release space for the old bitmap
}

The function does not check if position is within the size, neither it checks if the new bitmap is already there, etc. I just wanted to concentrate on the question you asked.

cyanide
  • 3,512
  • 3
  • 20
  • 31