简体   繁体   English

如何使用phonegap创建数据库来存储日志?

[英]How to create a database to store logs using phonegap?

I am dsigning an app for iOS using phonegap. 我正在使用phonegap设计适用于iOS的应用程序。 What I want to do is log down the date and time each time when the user pressed a button on the screen, and be able to view the log on device screen with an admin access. 我要做的是每次用户按下屏幕上的按钮时记录下来的日期和时间,并能够以管理员权限查看登录设备屏幕。 I know I have to create some sort of a database to store the info, but can someone give me an example on how to create one as I'm new to phonegap and not sure how to do that. 我知道我必须创建某种数据库来存储信息,但是有人可以给我一个关于如何创建一个示例的示例,因为我对Phonegap还是陌生的,但不确定该怎么做。

It seems as localStorage would be sufficient for your problem. 看来localStorage足以解决您的问题。 You can simlply Json.stringify your data and put it to the local storage. 您可以简单地Json.stringify您的数据并将其放入本地存储。 Later get it from there and json.parse it. 稍后从那里获取并进行json.parse。 No phonegap needed just pure html5. 没有phonegap只需纯html5。 Try search for localstorage HTM5 尝试搜索本地存储HTM5

In my opinion the best SQLite Plugin for saving a lot of data is this plugin: 我认为,用于保存大量数据的最佳SQLite插件是此插件:

https://github.com/brodysoft/Cordova-SQLitePlugin https://github.com/brodysoft/Cordova-SQLitePlugin

There is no limit of storing. 没有存储限制。 In this post How to compact SQL instructions in Cordova? 在这篇文章中, 如何在Cordova中压缩SQL指令? I have written how to compact SQLite instructions, so you have not all this event overload. 我已经写了如何压缩SQLite指令,因此您没有所有此类事件重载。

But do you really want save every tap? 但是,您真的要保存每次点击吗? That will be a lot of scripting work. 那将是很多脚本工作。

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

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