我在“assets”文件夹下有一个内部sqlite数据库,其中存储了100个用户名和相应的密码,如何通过phonegap访问它?我读过
http://docs.phonegap.com/en/1.6.1/cordova_storage_storage.md.html#Storage
connecting to sqlite database from phonegap html file for android
http://wiki.phonegap.com/w/page/16494756/Adding-SQL-Database-support-to-your-iPhone-App
我仍然不知道如何连接到我已经创建的内部数据库,dbname=userauthttablename=regparameters=usrnm,psw使用这里的任何答案都是非常令人鼓舞的。

最佳答案

/**
 * Creates / Opens a connection to DB
 */
DB.openDB = function() {
    try {
        if (!window.openDatabase) {
            //alert('Cannot open database!');
        } else {
            var shortName = 'db_name';
            var version = '1.0';
            var displayName = 'DBNAME';
            var maxSize = (DEVICE_TYPE == DEVICE_ANDROID || DEVICE_TYPE == DEVICE_ANDROID_TAB) ? 5242880 : 1000000; ////819200; //65536; // in bytes // increased to support Android//163840; //
            this.vocabDB = window.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            this.DBSupported = true;
        }
    } catch(e) {
        //console.log("DB Error handling code goes here.");
        //console.log(e);
        return;
    }
}

07-26 09:42
查看更多