How to force a cache clearing using Universal Image Loader Android?

后端 未结 3 475
旧巷少年郎
旧巷少年郎 2020-11-30 05:13

I am using UIL to load images in a listview.

When I long press an image in the listview, I show a dialog to modify that picture, replacing it with a new one using t

相关标签:
3条回答
  • 2020-11-30 05:32

    I think you should delete cached image in memory cache when opening dialog. Use MemoryCacheUtil for that:

    MemoryCacheUtils.removeFromCache(imageUrl, imageLoader.getMemoryCache());
    
    0 讨论(0)
  • 2020-11-30 05:48

    If you are caching it both in memory and disc, for example:

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())         
            .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) 
            .discCache(new UnlimitedDiscCache(cacheDir)) 
    .........
    

    Ensure you remove it from both of them, then reload your image view.

    MemoryCacheUtils.removeFromCache(url, ImageLoader.getInstance().getMemoryCache());
    DiscCacheUtils.removeFromCache(url, ImageLoader.getInstance().getDiscCache());
    
    0 讨论(0)
  • 2020-11-30 05:50

    This should work:

    imageLoader.clearMemoryCache();
    
    0 讨论(0)
提交回复
热议问题