I was using websql for my app, but unfortunately it is no more more working for new apps on IOS. I have updated the code to use SQLite but it is not working either. Please anyone help me in this regard. Any working example please.
Thanks in advance
I was using websql for my app, but unfortunately it is no more more working for new apps on IOS. I have updated the code to use SQLite but it is not working either. Please anyone help me in this regard. Any working example please.
Thanks in advance
Have you looked at these plugins? Storage - Apache Cordova
If so, which are you using?
here is the code
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
//alert(location.hostname);
db = window.sqlitePlugin.openDatabase("balaghdatabase", "1.5", "balaghulquran", 50000);
if (dbCreated)
db.transaction(getsura, transaction_error);
else
db.transaction(populateDB, transaction_error, populateDB_success);
}
function transaction_error(tx, error) {
$('#busy').hide()
alert("Database Error: here " + error + tx.message);alert('Please inform support, thank you');
}
What plugin are you using?
I’m using cordova-plugin-sqlite-2
I see a couple of issues with the above code:
dbCreated
doesn’t existgetsura
, populateDB
, and populateDB_success
don’t existWhen this code is failing what are you seeing in the remote debugger?
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
var db = window.sqlitePlugin.openDatabase('mydb.db', '1.0', '', 1);
db.transaction(function (txn) {
txn.executeSql('SELECT 42 AS `answer`', [], function (tx, res) {
var n=res.rows.item(0).answer; alert (n);//alert(res.rows.item(i).firstname);
console.log(res.rows.item(0)); // {"answer": 42}
document.getElementById("info").innerHTML=n;
});
});
}
IN BROWSER
Error: exec proxy not found for :: SQLitePlugin :: exec
cordova.js:989
Error: exec proxy not found for :: SQLitePlugin :: exec
IN MOBILE
No Response
No response in browser is expected. Cordova plugins only work in mobile apps.
Are you sure your onDeviceReady
function is being called? I would add many more debugging statements so you can track down the issue.
As far as statement shows it is being called, I have checked with alert as well. please could send updated code with debugging statements.
Thanks
When I mention debugging statements, normally I’m talking about using console.log
or perhaps alert
. For example:
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
console.log('onDeviceReady');
var db = window.sqlitePlugin.openDatabase('mydb.db', '1.0', '', 1);
console.log('Opened database', db);
db.transaction(function (txn) {
console.log('In transaction', txn);
txn.executeSql('SELECT 42 AS `answer`', [], function (tx, res) {
console.log('Got result', tx, res);
var n=res.rows.item(0).answer; alert (n);//alert(res.rows.item(i).firstname);
console.log(res.rows.item(0)); // {"answer": 42}
document.getElementById("info").innerHTML=n;
});
});
}
While there are more advanced ways of debugging, this can often give you very quick results.
If there’s no response on the Phone, the onDeviceReady
isn’t firing properly or remote debugging isn’t working properly.
I would suggest sharing a minimal example app so we can sort out what the problem is.
Issue resolved thank you very much. It was with package.json file.