在Android中使用的WebView网页保存在缓存中缓存、存在、网页、Android

2023-09-13 01:03:34 作者:小鬼頭

我的工作,我加载的WebView几个网站,现在我要保存网页,所以一段时间后,即使没有互联网的用户将能够看到这些网页的应用程序。但我困惑于如何保存整个网页的缓存或任何其他媒介。最主要的是,我们需要显示的页面后面,即使没有互联网。   有没有人来实现这一点。请提供一些演示code,因为这是我在高速缓存的第一次尝试。

I am working on an application where I load few websites in webview now I want to save webpages so after sometime even if there is not internet user will able to see those pages. But I am confused on how to save whole webpage in cache or any other medium. The main thing is we need to show pages back even if there is not internet. Has anyone implemented this before. Please provide some demo code as this is my first attempt on cache..

感谢您

推荐答案

最简单的方法是保存的缓存目录或任何其他网页(内部或外部存储)

The easiest way is save webpages in cache directory or any other(Internal or external storage)

您可以用得到的网页的数据 HttpClient.execute() HttpClient.get()现在同时你要下载图片或其他内容都绑定到该页面,现在,在你的应用程序,你必须检查是否连接存储在的.html 文件中的数据不可用连接然后加载保存在存储其中一个与文件页面://<定位你的网页中..>

You can get the data of web page using HttpClient.execute() or HttpClient.get() now store that data in .html file also you have to download images or other contents which are bind to that page, Now in your application you have to check for connection if connection not available then load the page which one you saved in storage with file://<location of your webpage..>

编辑:

我觉得用 HTML5 您可以显示脱机网页。 (我从来没有尝试过,但我提到它的一些博客)。请看关于HTML5 创建移动Web应用程序使用HTML 5,第3部分:让移动Web应用程序使用HTML 5 另外的这个

I think using HTML5 you can display off-line webpages. (I never tried this, but I referred some blogs on it). Look at this nice post about HTML5 Creating mobile Web applications with HTML 5, Part 3: Make mobile Web applications work offline with HTML 5 Also this

希望这会帮助你。