puneet dubey mudia puneet dubey mudia - 2 months ago 68x
Android Question

How to read data from sqlite .db file in HTML 5/cordova/Intel xdk

I am working with intel XDK and there I have a prepopulated .db file which i need to read inside my code. As we do in native app where we put db files in assets directory and then access those database by copying them in app's database directory. I am new to hybrid apps.


I did it with sql.js and xml http request using following piece of code:

var xhr = new XMLHttpRequest();
xhr.open('GET', 'yourDBname.db', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) 
mId = sessionStorage.i;
var uInt8Array = new Uint8Array(this.response);
var db = new SQL.Database(uInt8Array);
var contents = db.exec("SELECT * FROM ....your query");
// Do as per requirment