我怎样才能在Android的正确加载存档网页?加载、正确、网页、Android

由网友(Dirge. 挽歌)分享简介:我要的网页保存到本地。I want to save the webpage to local.我发现,有一种方法,以网页保存为归档文件I found that there is a method to save the webpage as an archive file.public void saveWeb...

我要的网页保存到本地。

I want to save the webpage to local.

我发现,有一种方法,以网页保存为归档文件

I found that there is a method to save the webpage as an archive file.

public void saveWebArchive (String filename)

不过,我什么也没得到,但胡言乱语,当我加载该文件。

However, I got nothing but gibberish when I load the file.

WebView webView = (WebView) rootView.findViewById(R.id.webview_layout);
String url = "http://www.yahoo.com";
webView.loadUrl(url);
String path = getFilesDir().getAbsolutePath() + File.separator + "yahoo" + ".html";
webView.saveWebArchive(path);
webView.loadUrl("file://" + path);

我是什么做错了吗?

What am I doing wrong?

推荐答案

WebArchive是一种特殊的文件格式,不能直接读取由的WebView (即使它是幸福的保存该页面格式)。

WebArchive is a special file format that isn't directly readable by a WebView (even though it's happy to save pages in that format).

如果你想在页面的HTML内容保存到您的设备,有记载的方法here.

If you're trying to save the HTML contents of the page onto your device, there is a method described here.

如果你真的想要的页面保存为WebArchive文件,请尝试这个帖子。如果需要存储与页面相关联的图形,CSS和其他非文本这种方法可能是有用的。

If you really want to save the page as a WebArchive file, try this post. This approach may be useful if you need to store the graphics, CSS, and other non-text associated with the page.

阅读全文

相关推荐

最新文章