在Android的WebView中,什么是`DomStorage`,`Database`,`AppCache`之间有什么不同? [英] In Android's WebView, what's the different between `DomStorage`, `Database`, `AppCache`?

查看:151
本文介绍了在Android的WebView中,什么是`DomStorage`,`Database`,`AppCache`之间有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的WebView中,什么是 DomStorage 之间的不同的数据库应用程序缓存

In Android's WebView, what's the different between DomStorage, Database, AppCache?

我很困惑与这三个设置。现在我需要的WebView,我可以使用的localStorage 在JavaScript的一个实例。结果
下面是一个例子:

I'm confused with these three settings. Now I need a instance of WebView that I can use localStorage in JavaScript.
Here is an example:

        if (localStorage['avatar_user_' + nick]) {
        obj.src = localStorage['avatar_user_' + nick];
    } else {
        var url = avatar_path + nick + '/avatar.jpg';
        new Oauth().img("jpeg", url,
            function(data) {
                if (data != '') {
                    obj.src = data;
                    localStorage['avatar_user_' + nick] = data;
                }
            }, function() {}
        );
    }

在code以上我真正得到的图像形成网络,这将是从localStroage下一次我需要它的负荷。但存储仅持续只要应​​用程序的续航时间。

In the code above I really get the image form the web, and it will be load from the localStroage next time I need it. But the storage only lasts as long as the app's life time.

如果我重新启动我的应用程序,然后图像会再次从网络负载。

If I restart my app then the image will be load from the web again.

设置我的WebView如下:

I setup my WebView as following:

        mWebSettings.setAppCacheEnabled(true);
    mWebSettings.setDomStorageEnabled(true);
    mWebSettings.setDatabaseEnabled(true);
    mWebSettings.setDatabasePath("file:///data/data/com.xxx/databases");

但我可以看到在文件中的文件:///data/data/com.xxx/databases 当我加入一些内容的localStorage保持不变。

but I can see the files in file:///data/data/com.xxx/databases keep unchanged when I'm adding something into localStorage.

所以,我的问题是如何让我的网页存储数据,并让他们的应用程序被关闭后?

So, my question is how to make my webpages store data and keep them after the app is closed?

和是,如果我在应用程序中使用多个网页视图,并指着 DatabasePath 在同一文件夹?

And is it matters if I use multiple WebView in a app and pointing the DatabasePath the the same folder?

如果你能告诉我 DomStorage 之间的不同的数据库应用程序缓存是那就更好了!

And if you can tell me the different between DomStorage, Database, AppCache is so much the better!

推荐答案

我不hundert%的肯定,但DomStorage看起来像WebStorage的代名词。这是将数据存储在客户端站点键值对的技术。结果
http://diveintohtml5.info/storage.html

I'm not hundert percent sure, but DomStorage seems like an synonym for WebStorage. This is a technique to store data on client site as key=value pairs.
http://diveintohtml5.info/storage.html

数据库意味着客户端SQL数据库将被启用。结果
http://www.html5rocks.com/en/tutorials/webdatabase/todo/

Database means that the client-side SQL database will be enabled.
http://www.html5rocks.com/en/tutorials/webdatabase/todo/

和应用程序缓存是使供离线使用整个网站的技术。结果
http://appcachefacts.info/

And AppCache is a technique to make whole websites available for offline usage.
http://appcachefacts.info/

这篇关于在Android的WebView中,什么是`DomStorage`,`Database`,`AppCache`之间有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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