Phonegap: easiest way to store data / Phonegap reference

前端 未结 2 1845
予麋鹿
予麋鹿 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 17:53

    The easiest way to implement a database is probably to use Lawnchair. It's pretty easy to use and out-of-the box probably does most of what you need (including searching). It's cross-browser, battle tested and degrades nicely through the use of adapters. There is an adapter for Blackberry, and a plugin that supports queries. Here is a quick example using the WebKit adapter, which is good for Android and iPhone, to show how simple it is.

     
    
    // Open local DB connection
    var lawnchair = new Lawnchair({table:'mytable', adaptor:'webkit'}, function(){
        // Lawnchair setup! 
    });
    // Getting some data out of the lawnchair database
    lawnchair.get('my_data_key', function(obj) {
        if (obj !== undefined) {
            lastSyncDate = obj.lastSync;
            dataList = obj.dataList;
        }
    });
    // Saving to the database
    lawnchair.save({key:'my_data_key', lastSync: currentTime, dataList: someData});
    

提交回复
热议问题