jeudi 5 mai 2016

Access the SQLite db which is externally created

I am creating a hybrid app by telerik app builder in visual studio. I am not able to access sqlite db which is created externally. But I can access the db which is created at run time. I referred some sites, those solutions are not worked for me. The following code will create db and access it while run time

var app = {};
app.db = null;

app.openDb = function () {
    var dbName = "Test.sqlite";

    //DB creation for Simulator
    if (window.navigator.simulator === true) {
        app.db = window.openDatabase(dbName, "1.0", "Test Database", 1073741824);
        console.log("Database Created!");
    }
    //DB creation for devices
    else {
        app.db = window.sqlitePlugin.openDatabase(dbName);
        console.log("Database Accessed!");
    }
}

I want to access the database which is present in the data folder. Please refer the image.

enter image description here

I tried to place the db in www folder and try to access it by the following code

app.db = window.sqlitePlugin.openDatabase({name: "Test.db", createFromLocation: 1});

It will give the following error

Uncaught TypeError: Cannot read property 'openDatabase' of undefined

So, how can I access the externally created sqlite db?

Aucun commentaire:

Enregistrer un commentaire