加载的WebView缓存图像到ImageView的 [英] load WebView cached image into an ImageView

查看:501
本文介绍了加载的WebView缓存图像到ImageView的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web视图使用这些设置缓存的图片放到一个目录:

I have a WebView that caches its images into a directory using these settings:

mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
mWebView.getSettings().setAppCacheMaxSize( 8 * 1024 * 1024 ); // 8MB
mWebView.getSettings().setAppCachePath(getApplicationContext().getCacheDir().getAbsolutePath());
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setAppCacheEnabled(true);

我希望能够加载正在使用此的WebView到ImageView的缓存图像。

I want to be able to load an image that is cached using this WebView into an ImageView.

我一直在寻找进入的目录,其中的缓存目录指向使用亚行的shell(/data/data/com.example.webviewtest/cache),我发现了以下文件夹:

I was looking into the directory where the cache dir points to using adb shell (/data/data/com.example.webviewtest/cache), and I found the following folders:

  • ApplicationCache.db
  • com.android.opengl.shaders_cache
  • webviewCacheChromium

有没有一些方法来查找这些目录下载的图片吗?

Is there some way to find a downloaded image in these directories?

如果是的,我可以将它们加载到一个位图(在ImageView的使用)?

If yes, can I load them into a Bitmap (to use in ImageView)?

推荐答案

在资源保存里面ApplicationCache.db这是一个SQLite数据库。你要找的图像可以从数据库中检索,但数据库的格式可能的Andr​​oid版本,以便实现兼容的方式做,这将是难以之间切换。我想你会更好下载和高速缓存的WebView的图像自己,外面。

The resources are saved inside ApplicationCache.db which is an SQLite database. The images you're looking for could be retrieved from the database, but the format of the database may change between Android versions so implementing a compatible way to do this will be hard. I think you'd be better off downloading and caching the images yourself, outside of the WebView.

这篇关于加载的WebView缓存图像到ImageView的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆