vendredi 8 janvier 2016

Copying a prepopulated sqlite database in phonegap android from assets/www to the default location

I have an sqlite database test_db.db i have kept in the www folder i am using cordova cli to build android app on my local machine.

when i am trying to open the database it is opening new database instead of accessing the prepopulated.

I tested this using following code.

// Open the existing database var db = window.sqlitePlugin.openDatabase({ name : "test_db.db" });

db.transaction(function (tx) {

    alert("database opened");

    var _strQuery = "select * from mst_users;";

    tx.executeSql(_strQuery, [], function (tx, res) {

        alert("Populated Successfully with " + res.rows.length + " Records.");

    }, CommonError);



}, CommonError, DoNothing);

And every time i am getting an error that table mst_users does not exist but it is there in the prepopulated db.

I have tried various things for achieving this but yet stucked. I want access the data in the prepopulated database .

Any help is really appreciated..

Aucun commentaire:

Enregistrer un commentaire