I m using cordova to build hybrid android app and i m using this function which return database object its works fine everywhere in app
function openDB() {
var dbUser = null;
var dBVersion = localStorage.getItem("db_version");
if (dBVersion == null) {
try {
if (!window.openDatabase) {
console.log('db init failed');
} else {
dbUser = window.openDatabase("dbname", "1.0.1", "local", 100000);
}
} catch(error) {
console.log(e);
if (e.name == "INVALID_STATE_ERR") {
console.log("Invalid database version.");
} else {
console.log("Unknown error " + e + ".");
}
}
} else {
dbUser = window.openDatabase("dbname", dBVersion, "local", 100000);
}
console.log(dbUser);
//initialize tables
if (dbUser != null)
createTables(dbUser);
return dbUser;
}
but when i use social plugin like facebook and foursquare and return to app then my app wont able to access the database and give error
Uncaught Error: SECURITY_ERR: DOM Exception 18 at file:///android_asset/www/js/DB.js:27
dbUser = window.openDatabase("dbname", dBVersion, "local", 100000);
and the my app become blank as its wont able to access the database.