Android的web视图 - 从缓存中载入图像 [英] Android WebView - Load Images from cache

查看:128
本文介绍了Android的web视图 - 从缓存中载入图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我访问包含图像的网站,并没有表现出自己的格式,我的WebView可以节省大量的缓存对SD卡。当我尝试打开它们时,默认的Andr​​oid文件管理器显示未找到文件类型。然后,我改变了一些人的格式(主要是大尺寸的一个),jpg和宾果,他们是我在网页上看到的图像。

My webview saves lot of cache on SD Card when I visit a site which contains images and they don't show their format. When I try to open them, the default Android file manager says "File type not found". Then I changed the format of some of them(mostly the big size one) to .jpg and bingo, they are the images I saw on the webpage.

警句:我想从打开的图像,被保存为缓存,在另一个活动场所,我会去和所有的缓存文件重命名为.JPG,然后打电话给他们或者有另一种方式来做到这一点

Punchline: I want to open the images from that sites that are saved as cache, in another activity, would I have to go on and rename all the cache files to .jpg then call them or there is another way to do it.

感谢您。

推荐答案

您可以使用的 BitmapFactory 打开这些图像文件。你可以试试:

You can use the BitmapFactory to open these images files. You can try:

- decodeFile(String pathName)

如果它提出了一些问题的延伸,尝试德codeStream(InputStream为),它收到的InputStream ,它应该工作。

If it gives some problem with the extension, try decodeStream (InputStream is), it receive an InputStream and it should work.

您可以列出一个文件夹文件:

You can list a folder with File:

File f = new File(Environment
          .getExternalStorageDirectory()
          .getAbsolutePath());

File[] files = f.listFiles();
for (File file : files){
   //Do something with this file
}

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

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