Phonegap: easiest way to store data / Phonegap reference

前端 未结 2 1816
予麋鹿
予麋鹿 2021-02-06 17:15

I\'m looking for the following info:

  • Full Phonegap reference (couldn\'t find it on their site)
  • What\'s the easiest way to implement a database within Phon
2条回答
  •  一整个雨季
    2021-02-06 18:08

    Update 2015

    The answer below is very out date (and since it recently got an upvote I thought I better readdress it), the Cordova Docs is now the definitive place for documentation, though currently the plugin docs link to the NPM pages which are kind of in transition and a mess. As for the best way to store date, sqllite database that was built into webkit is either gone or deprecated. Lawnchair has been the defacto standard for the past 5 years, as you could swap storage engines in and out, LocalStorage is the simplest way to store data, but beware you around a 5 megs maximum (and I have run into corruption issues with it). I would recommend looking at something like sqllite plugin if you need more than 5 megs (it also has a LawnChair adaptor), or PouchDB and its Cordova Adaptor if you need syncronization to the cloud.

    I've left the original answer for posterity...

    Original Answer - Circa 2010

    The Wiki is the closest thing that phonegap has to a full reference, though it isn't the easiest thing to find on their site. The Javascript API page is probably the most complete reference on external functions available, although it may be a little out of date. The best thing you can do, if something isn't functioning as documented, is go to the Javascript API is to go to the Javascript source (which differs from device to device, in iphone for example, you can go to github and look at the javascript classes and see their exact parameters (you may have to dig into other parts of the source code to see exactly what is going on, but all of the code is pretty straightforward).

    As for implementing a database, the best thing to use is the sqlite database built into webkit. Jonathan Stark's excellent book, Building iPhone Apps with HTML, CSS, and JavaScript, has a chapter on doing this.

提交回复
热议问题