Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中从缓存中检索图像_Android - Fatal编程技术网

如何在android中从缓存中检索图像

如何在android中从缓存中检索图像,android,Android,以下是代码片段: private static Drawable getDrawableFromUrl(final String url) throws IOException, MalformedURLException { URL uurl = new URL(url); URLConnection connection = uurl.openConnection(); connection.setUseCaches(true); //sha

以下是代码片段:

private static Drawable getDrawableFromUrl(final String url) throws IOException, MalformedURLException {
        URL uurl = new URL(url);
        URLConnection connection = uurl.openConnection();
        connection.setUseCaches(true);  //share cache with browser
        Object response = connection.getContent();
        return Drawable.createFromStream(((InputStream)response), uurl.getFile());
    }

那么现在我如何在下次和以后的时间从缓存中检索它呢?

setUseCaches
并不意味着位图被缓存在某个地方。。。它只是控制此连接是否允许使用缓存

如果您想对位图使用缓存,我强烈建议您使用库