I use cordova to create a hybrid application for Android and I m using this function that returns a database object, its works perfectly everywhere in the application
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);
if (dbUser != null)
createTables(dbUser);
return dbUser;
}
but when I use a social plugin like facebook and foursquare and return to the application, then my application will not be able to access the database and give an error
Uncaught Error: SECURITY_ERR: DOM Exception 18 at file:
dbUser = window.openDatabase("dbname", dBVersion, "local", 100000);
and my application becomes empty because it will not be able to access the database.
source
share