存储的WebView离线浏览的Andr​​oid [英] Storing a WebView for offline browsing Android

查看:103
本文介绍了存储的WebView离线浏览的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是强迫了Android,一旦加载页面来存储的WebView到媒体(例如SD卡)的最佳方法是什么?

What would be the best way to force the android to store a webview to a media (say an sd card) once the page is loaded?

一些细节:

- 每个页面将是丰富的图片,脚本和样式。

-Each page will be rich with images, scripts and styling.

- 每个页面将约0.5-1兆

-Each page will be about .5-1 megabyte

- 它们将被保存,一旦OnFinishedLoading覆盖之称。

-They will be saved once the OnFinishedLoading Override is called.

-Ideally,这将是最好将其保存到SD卡(的想法?)然后使用本地回购打开它备份

-Ideally, it would be best to save it to the SD Card (thoughts?) then use the local repo to open it back up

不知道我是否应该只使用一个SQL数据库为webviews,或采取每个视图,做一个写出到一个文件 - 如果我做了后者,这将是最容易的,所以我没有写一个完整的WebCrawler的得到每个文件链接?

Not sure if I should just use a sql database for the webviews, or take each view and do a write out to a file - and if I do the latter, what would be the easiest so I don't have to write a full webcrawler to get each file linked?

推荐答案

为了使用缓存在Android上,你需要与你的HTML提供了一个HTML5清单文件。

In order to use caching on Android, you need to provide an HTML5 manifest file along with your HTML.

<!DOCTYPE html>
<html lang="en" manifest="manifest.file">
<head> ...

缓存机制将缓存的任何条目,您将列出清单文件到SQLite数据库。请记住,数据库是每个应用程序,而不是每个web视图。 (我有很多的问题,这一点)。

The caching mechanism will cache whatever entries you will list in the manifest file into an SQLite database. Keep in mind that the database is per app, not per webview. (I had a lot of problems with this).

本文章解释了所有你需要实现这一目标的步骤。 <一href="http://web.archive.org/web/20140314001433/http://alex.tapmania.org/2010/11/html5-cache-android-webview.html" rel="nofollow">http://web.archive.org/web/20140314001433/http://alex.tapmania.org/2010/11/html5-cache-android-webview.html

This article explains all the steps you need to take to achieve this. http://web.archive.org/web/20140314001433/http://alex.tapmania.org/2010/11/html5-cache-android-webview.html

您可以做一个hello世界的例子使用该页面缓存: http://html5demos.com/offlineapp <​​/A>

You can do a hello-world example for caching using this page: http://html5demos.com/offlineapp

您可以保存在SD卡上的缓存,只要你加WRITE_EXTERNAL_STORAG​​E权限的应用程序清单。

You can save the cache on the SD card, as long as you add the WRITE_EXTERNAL_STORAGE permission to the application manifest.

祝你好运!

这篇关于存储的WebView离线浏览的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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