Piraba
Piraba

Reputation: 7014

Cordova PhoneGap upgrade to 5.1.1 from 2.2.0

I have Cordova application which is version 2.2.0. Now I want to upgrade, I have done upgrade part, after upgrading, application images are not display, it came blank screen. even splash screen also not came. Here is my code

Now I reached to some level. What I have simulated the application, is about SQLitePlugin issue. When Open database say db.cordova is not define

How database installation - copy database from db folder to android installation location. That worked fine.

This is my database:

    var DB              = new Object();
DB.isDBSupported    = false;
DB.isDBCreated      = false;
DB.vocabDB          = null;
DB.tables           = ['userResponses', 'wordGroups', 'words', 'wordMapping', 'checkExists', 'patch_version']
DB.createdTables    = 0;
DB.setupCallback    = null;
DB.curQP            = null;
DB.accountStatus    = false;
DB.sfx              = true;
DB.showWarnings     = true;
DB.firstLaunch      = false;

DB.initDB = function(callback) {
    this.setupCallback = callback || function(){/*console.log("null function called")*/};
    this.openDB();
    var db = this;
    if(!isPhoneGap()) {
        _.delay(this.checkDB.bind(this), 500);
    }
}

DB.checkDB = function() {
    var db = this;
    this.vocabDB.transaction(
        function (t) {
            t.executeSql('DROP TABLE checkExists', [], db.setupDBResultHandler.bind(db), db.setupDBErrorHandler.bind(db, ">>delete exists"))
        }
    )
}

DB.openDB = function() {

    try {
        if (!window.openDatabase) {
            alert('Cannot open database!');
        } else {
            var shortName = 'sns2';
            var version = '1.0';
            var displayName = 'sns2';
            var maxSize = (isAndroid()) ? 5242880 : 1000000;

            if(!isPhoneGap()) {
                this.vocabDB = window.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            } else if(isAndroid()) {
                utils.log("ANDROID DATABASE .. ");
                this.vocabDB = window.sqlitePlugin.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            } else if(isIOS()) {
                utils.log("iOS DATABASE .. ");
                this.vocabDB = window.sqlitePlugin.openDatabase(shortName, version, displayName, maxSize, this.DBCreated);
            }
            this.DBSupported = true;
            if(isPhoneGap()) {
                this.setupCallback();
            }

        }
    } catch(e) {
        alert("Unable to open db." + e.message);
        return;
    }
}

Service.js

function getGroupCategory(handler) {
    console.log("selecting wordGroups");
    DB.vocabDB
    .transaction(function(t) {
                 t
                 .executeSql('SELECT * FROM categories', [], function(transaction, resultSet) {
                             handler(transaction, resultSet);
                             }, DB.transactionErrorHandler
                             .bind(DB, "Error while selecting wordGroups"));
                 })
}

When i called this method i got this error message could not prepare statement(1 no such table) error code 5 table is avaibale

Please any suggestion or idea..

Upvotes: 26

Views: 666

Answers (1)

LilaQ
LilaQ

Reputation: 350

I would suggest to start clean with 5.1.1. This way you can prevent problems that may easily be caused by upgrading the whole thing, and will keep you searching for the root of the problems.

This might sound like more work, but it pretty sure will be less of a hassle than upgrading, at least that is what my personal experience taught me with PhoneGap.

Upvotes: 3

Related Questions