Closed sangariv closed 10 years ago
How did you add the plugin and what platform are you using. What is the exact error message, does it showing window.plugins.sqlDB undefined?
hi, i have copied the databasehelper.java and sqldb.java under src folder of my project. Then added the sqldb.js inside www folder. Then added my demo.sqlite file under assets directory. and called in javscript as you said . function dbcopy() { window.plugins.sqlDB.copy("demo",copysuccess,copyerror); }
Do not add the plugin manually, please add the plugin using the Cordova CLI -
cordova plugin add https://github.com/an-rahulpandey/cordova-plugin-dbcopy.git
ok let me add using this.Thankyou
Hi, i my sample database name is test.sqlite have defined like this var db = window.plugins.sqlDB.copy("test",copysuccess,copyerror); alert(db); but i get it as "undefined" please guide me where i am wrong.
Use the demo code as shown in the read me, call the dbcopy function and put the console.log or alert in the copysuccess method. If you are using any IDE, you can check for error in their log section.
HI, I am having my "test.sqlite" inside assets directory and trying to call like below.still i get alert as copy error. document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("onDeviceReady");
var db = window.plugins.sqlDB.copy("test",copysuccess,copyerror);
alert(db);
}
function copysuccess() { alert("copysuccess");
}
function copyerror() { alert("copyerror");
}
First delete your existing app from the device, then compile and run the new app with this change
var db = window.plugins.sqlDB.copy("test.sqlite",copysuccess,copyerror);
Also if you are using eclipse, check the Logcat. I have not removed the logging from the current code, it will also give you the exact error message.
One more thing, it goes to copy error method - 1) When there is a problem while copying the database. 2) When the database already exists in the current location.
You can use following method to know the exact issue -
function copyerror(e) { alert(JSON.stringify(e)); }
Hi, Just now i got into copy success function i just changed the line var db = window.plugins.sqlDB.copy("test.sqlite",copysuccess,copyerror); into var db = window.plugins.sqlDB.copy("test.db",copysuccess,copyerror);
Thanks
HI, select query inside copy success always returns "no table found".below is my code document.addEventListener("deviceready", onDeviceReady, false);
var db function onDeviceReady() { alert("onDeviceReady"); window.plugins.sqlDB.copy("Databases.db",copysuccess,copyerror);
}
function copysuccess() { alert("copysuccess"); db = window.openDatabase("Databases", "1.0", "Test DB", 1000000);
db.transaction(queryDB, errorCB);
}
function copyerror() { alert("copyerror"); //db.transaction(queryDB, errorCB);
}
function queryDB(tx) {
alert("started");
tx.executeSql("select id from halal_product",[],renderEntries,errorCB);
}
function renderEntries(tx,results){
alert("res.rows.length: " + results.rows.length);
}
function errorCB(err) {
alert("Error processing SQL : "+err.message);
}
You have to use SQLite Plugin - https://github.com/brodysoft/Cordova-SQLitePlugin
yes i have used it alerady but it says no table found
Run the code in simulator and then copy the db from the data directory. Open the downloaded db in Sqlitebrowser and check if everything is proper or not.
HI, if i give the path like this db = window.sqlitePlugin.openDatabase('/data/data/com.qr.app/databases/qrapp.db',"1.0", "qr", 1000000); it opens correctly.
var db = window.sqlitePlugin.openDatabase("Databases.db", "1.0", "Test DB", -1);
In your previous code there was no .db extension.
I have also the problem that I am not able to talk to my sqlite db on an iphone. In xcode I have this warning:
warning: no rule to process file '/Library/WebServer/Documents/rcs/dev/platforms/ios/Myapp/Plugins/me.rahul.plugins.sqlDB/sqlDB.h' of type sourcecode.c.h for architecture arm64
In the debug console I receive this:
I have no problems on Android!
I created also an issue on Stackoverflow with more info regarding my code: http://stackoverflow.com/q/36705044/2425177
Any ideas?
See #25
Can you help me? I added the sqlDB plugin using cordova, but still having call to unknown plugin: sqlDB error.
@IoTFusion Try building your project with Cordova CLI.
when db copy it crash app.
Hi,
Make sure db file is present inside the www folder.
my db present in www folder of cordova-plugin-dbcopy basically my database copied but not whole database. my database size is 25 MB and when copy just start and reach to just 12 KB my app crashed. it's says like "unfortunatley , your app closed".
i am using Telerik app builder and my code as below my code:
window.plugins.sqlDB.copy("mydb",null, function (error) { alert(JSON.stringify(error)); console.log(JSON.stringify(error));
});
also i tried
window.plugins.sqlDB.copy("mydb",0,null, function (error) { alert(JSON.stringify(error)); console.log(JSON.stringify(error));
});
@milanifour Can you debug using Android Monitor located inside android sdk tools directory - https://developer.android.com/studio/profile/monitor.html
Hi Can you guide me to use this plugin in commandline ? window.plugins is always undefined to me.