question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove image from caches

See original GitHub issue

Hey 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:closed
  • Created 11 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nostra13commented, Jan 15, 2013

To remove image from disc cache:

File imageFile = imageLoader.getDiscCache().get(imageUri)
if (imageFile.exists()) {
    imageFile.delete();
}

To remove image from memory cache:

MemoryCacheUtil.removeFromCache(imageUri, imageLoader.getMemoryCache());
0reactions
oseamiyacommented, Jun 14, 2021

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 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to clear or replace a cached image - Stack Overflow
No, there is no way to force a file in a browser cache to be deleted, either by the web ...
Read more >
How to clear cached images and files on Chrome ... - YouTube
How to clear cached images and files on Chrome browser on your computerSteps:To do this, open chromeclick on the 3 dots on the...
Read more >
Remove images from your cache | WordPress.org
Our CDN cache is automatically cleared every day, it caches all the images from your Media Library. If the images are still on...
Read more >
How to delete image cache memory? - General Discussions
i deleted the files in the folder /var/lib/docker/overlay2/ now I can't build the image and get error Step 1/6 : FROM node:12.13.1 AS...
Read more >
Will clearing image cache delete images from gallery?
The device should only clear the thumbnail cache which is used to show the images faster in the gallery when you scroll.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found