Remove image from caches
See original GitHub issueHey i’d like to first say this was a lifesaver for an app I am working on. I was plagued with outofmemory issue until I used your library. I would like to request a feature for removing a single image from the cache. The reason for this is in my application I use a listview to display some images. Now the user can change the image by clicking on it. However in my implementation I name the images in a particular way ie. the image in position one will be labeled home_position1.jpg. now when I want to change that image to another one I rename the image with that naming convention and reload the image. however since it is the same name the cache still displays the old image. I know there is the clearCache option but then that blows away the other images when they didn’t change and they will be recached. I would think a remove single item from the cache would solve this problem. something like: in BaseDiscCache:
public void removeItem(String imageUri) {
String fileName = fileNameGenerator.generate(key);
File deleteMe = new File(cacheDir, fileName);
deleteMe..delete()
}
and in BaseMemoryCache
public void removeItem(String imageUri) {
ImageSize targetSize = getImageSizeScaleTo(imageView);
String memoryCacheKey = MemoryCacheUtil.generateKey(uri, targetSize);
softMap.remove(memoryCacheKey);
}
Issue Analytics
- State:
- Created 11 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
To remove image from disc cache:
To remove image from memory cache:
public void DeleteCachedImage(String imageUrl){ ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this.context).build(); (this.imgLoader = ImageLoader.getInstance()).init(config); final ImageLoader imgLoader = this.imgLoader; ImageLoader.getInstance().getDiskCache().get(imageUrl).delete(); }
This should help you .