加载的WebView缓存图像到ImageView的缓存、图像、加载、ImageView

由网友(江城子)分享简介:我有一个web视图使用这些设置缓存的图片放到一个目录:I have a WebView that caches its images into a directory using these settings:mWebView.getSettings().setCacheMode(WebSettings.LOAD_...

我有一个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.

阅读全文

相关推荐

最新文章