简体   繁体   English

在iOS / Android上的HTML5混合应用中持久存储的可靠方法

[英]Reliable method for persistent storage in HTML5 hybrid app on iOS/Android

I, like many others, am building an iOS and Android Hybrid App with HTML5/Javascript and a bridge (Phonegap/Intel XDK). 我和其他许多人一样,正在使用HTML5 / Javascript和桥(Phonegap / Intel XDK)构建iOS和Android混合应用程序。 I have yet to find a definitive answer on persistent storage, eg storing app settings for the lifetime of the app. 我还没有找到关于持久性存储的明确答案,例如在应用程序的整个生命周期内存储应用程序设置。

Posts like: is localStorage on iPad Safari guaranteed to be persistent? 像这样的帖子: iPad Safari上的localStorage是否保证是持久的? suggest there is no guarantee that settings stored will persist. 建议不能保证存储的设置将持续存在。

Can anyone put my mind at rest and give a decent answer as to whether it's possible? 任何人都可以让我休息一下,就是否可能给出一个体面的答案? A lot of useful apps are potentially useless without the ability to store user entered data. 如果没有存储用户输入的数据的功能,许多有用的应用程序可能无用。

I have played with lawnchair.js http://brian.io/lawnchair/ and am heading down this route. 我玩过grasschair.js http://brian.io/lawnchair/,并且正沿着这条路线前进。 Can anyone too suggest whether this solves the problem or suggest the best persistent storage option in their opinion? 任何人都可以提出自己的看法,这是否可以解决问题或提出最佳持久存储选项?

Local storage is rather reliable method. 本地存储是相当可靠的方法。 This data removes only when user removes app from his device. 仅当用户从其设备中删除应用程序时,此数据才会删除。 You can also save data with WebSQL DB for Android devices. 您还可以使用适用于Android设备的WebSQL DB保存数据。 But it's rather uncomfortably. 但这是相当不舒服的。 Or you can use File API to save settings in folder, like .yourapp, and read data from this file. 或者,您可以使用File API将设置保存在文件夹(如.yourapp)中,并从该文件读取数据。 But user can remove this folder. 但是用户可以删除该文件夹。 So I recommend localStorage. 因此,我建议使用localStorage。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM