Android – phoneGap Android – Populate database once “Error processing SQL:1”

androidcordovadatabasepopulate

I am trying to avoid populate the database if the database exists but when I try to cancel this line in my code I get "Error processing SQL:1"

tx.executeSql('DROP TABLE IF EXISTS DEMO');

this is my whole populate function

 function populateDB(tx) {
        tx.executeSql('DROP TABLE IF EXISTS DEMO');
        tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, word TEXT NOT NULL');
        tx.executeSql('INSERT INTO DEMO (id, word) VALUES ("1", "Apple")');
        tx.executeSql('INSERT INTO DEMO (id, word) VALUES ("2", "Orange")');

    }

Best Answer

Why dont you use

CREATE TABLE IF NOT EXISTS DEMO  (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, kword TEXT NOT NULL, eword TEXT NOT NULL, pronoun TEXT NOT NULL, level INTEGER NOT NULL)
Related Topic