如何在iOS中使用Cordova永久存储数据? [英] How store data permanently in iOS with Cordova?

查看:399
本文介绍了如何在iOS中使用Cordova永久存储数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线阅读许多资源,我无法找到有关哪种类型的存储在iOS中是永久的一致信息。大多数人说使用PhoneGap / Cordova存储API。但是文档提到 window.localStorage ,并没有明确声明使用任何方法都不会使用localStorage,也没有提到WebSQL,

Reading many sources online, I cannot find consistent information on which type of storage is permanent in iOS. Most say to use PhoneGap/Cordova Storage API. But the documentation mentions window.localStorage and makes no clear declaration that using any of the methods won't use localStorage and there's no mention of WebSQL,

http://cordova.apache .org / docs / en / 3.0.0 / cordova_storage_storage.md.html

此页面 http://www.html5rocks.com/en/tutorials/offline/quota-research/ ,表示只有webSQL永久在iOS。但是我如何知道哪些API将在Cordova中使用WebSQL?

And this page http://www.html5rocks.com/en/tutorials/offline/quota-research/ , indicates that only webSQL is permanent on iOS. But how do I know which API will use WebSQL in Cordova?

我使用 window.openDatabase()?还有什么?

推荐答案

我认为你对Phonegap Storage API的描述感到困惑。

I think you are confused by the description of Phonegap Storage API.

这取决于你的数据有多大。您可以同时使用WebSQL或 localStorage 。他们都被Cordova认为是持久的。使用WebSQL或localStorage会将您的数据存储在缓存中。

It depends how big your data is. You can use both WebSQL or localStorage. Both of them are considered as "persistent" by Cordova. Using either WebSQL or localStorage will store your data in cache.


但是我如何知道哪些API会在Cordova中使用WebSQL?

But how do I know which API will use WebSQL in Cordova?

使用 var db = window.openDatabase(Database,1.0,test,200000);

如果您的数据很小,可以使用localStorage,它允许您在键值对中存储数据。因此,你将你的数据库定义为

If your data is small, you can use localStorage which allows you to store data in key-value pairs. Thus, you'll define your database as

window.localStorage.setItem("key", "value");

这篇关于如何在iOS中使用Cordova永久存储数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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