What are the requirements for PhoneGap database application for IPhone?

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

I would like to create a simple application accessing a database.

Does PhoneGap has this feature in its framework?

Which database technology does it use? MySQL? Any database?

What are the requirements for developing a PhoneGap database application for IPhone?

回答1:

Database (the Sqlite database) is baked right into Webkit (and Safari), though you do get some added functionality from Phonegap (the ability to pre-populate a Database). But you can just develop in HTML5 and Javascript to start. Apple provides a reference for Client Side storage. If you are looking for some sample code to play with, here is a little testbed I came up with to play with HTML5 databases. Note: when I say HTML5 databases, I mean Webkit as Mozilla is skeptical about adding an SQL database to HTML5 at all.



回答2:

Though PhoneGap recommends using the websql as a means of data storage, it should be mentioned (but its not) that the responses from queries are not instantaneously returned. This is just simply a limitation of using Phonegap. Here is a function I've used to tie a websql database query with a particular action.

http://snipplr.com/view/50724/query-local-database-with-targeted-callback-and-custom-arguements/

For smaller chunks of data that you want to store on the device you can use LocalStorage. I've found it reasonable to use JSON.stringify to convert a simple object into a string to be stored in LocalStorage. And upon retrieval JSON.parse it. Here is another snippet to assist in using this method.

http://snipplr.com/view/54570/local-storage-html5-wrapper/



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!