【问题标题】:Clear BitMap Cache - koush ion清除位图缓存 - koush ion
【发布时间】:2014-10-14 09:25:18
【问题描述】:

我想清除位图缓存,但我不确定如何清除位图。 我正在使用 Koush Ion 库加载图片

try {
            bitmap = Ion.with(context).load(URLimage).withBitmap().asBitmap().get();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ExecutionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

每次单击按钮时,我都需要清除位图缓存。 在此先感谢

【问题讨论】:

    标签: android caching bitmap ion-koush


    【解决方案1】:

    使用Ion.getDefault(context).getCache().clear()清除文件缓存。

    使用Ion.getDefault(context).getBitmapCache().clear() 清除内存中的位图缓存。

    查看相应方法的来源: https://github.com/koush/AndroidAsync/blob/master/AndroidAsync/src/com/koushikdutta/async/util/FileCache.java#L292 https://github.com/koush/ion/blob/master/ion/src/com/koushikdutta/ion/bitmap/IonBitmapCache.java#L63

    Ion.dump() 不会清除缓存。它只会将一些调试信息打印到日志中。您也可以查找它的源代码。

    【讨论】:

      【解决方案2】:

      试试这个可能有帮助,我用这个代码来清除我的网络数据缓存;

      Ion.getDefault(context).configure().getResponseCache().clear()

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-04-06
        • 1970-01-01
        • 1970-01-01
        • 2013-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多