- I created a database using SQLite
- I export the database .db format
- Then I save the database files in the www folder on Intel XDK
- How to call the database ??
please help me,.,
Success! Subscription added.
Success! Subscription removed.
Sorry, you must verify to complete this action. Please click the verification link in your email. You may re-send via your profile.
please help me,.,
Link Copied
You have to import your db when you start up the app and then use where required. You can create a simple app with one of our sample apps or templates and write your import script in deviceready or document.ready depending on whether you are using webapp or cordova app.
Swati
I have some problems to open the .db file, could you share with me the few lines of code to connect to the database?
Thanks a lot
Davide
Are you using an plugin?
I am using com.brodysoft.sqlitePlugin. With this one I open the db with this command> db = window.sqlitePlugin.openDatabase({name: wNomeDB, location: 2});
Unfortunately, to test any app with plugins, you need to test on device. The emulator does not run yet.
You can also build a custom app preview. This will build an app preview that contains your plugins.
This functionality can be found on the debug tab of the XDK.
Yes, it is true. I do the same.
I am waiting very anxious this new tool in XDK, not only for this plugin, but all.
checkout my simple project :
https://www.dropbox.com/s/2u1l4eh3x734h1m/intel_XDK_%28programsederhana%29.zip?dl=0
*note : create database using "sqlite browser"
Hi,
i have some problem to read a sqlLite db.
I add in my Intel xdk project the plugin cordova-sqlite-storage and i have add my .db file in www folder.
In index.html I use this code:
document.addEventListener("deviceready", onDeviceReady, false); function successCallback(db) { alert("successo : "+db); } function errorCallback(db) { alert("error : "+db); } function onDeviceReady() { var db = window.sqlitePlugin.openDatabase({name: "consiglinonna.db", createFromLocation: 1, androidLockWorkaround: 1}); //, function(db) { db.transaction(function(tx) { alert('ciao'); //tx.executeSql("SELECT * FROM 'categorie'", [], function(tx, res) { tx.executeSql("SELECT * FROM categorie", [], function(tx, res) { alert("res: " + JSON.stringify(res)); alert("res1: " + res.rows[0]); }, function(error) { alert('SELECT error: ' + error.message); }); }, function(err,a,b,c) { alert('Open database ERROR: ' + JSON.stringify(err)); // alert(err+"\n"+a+"\n"+b+"\n"+c); }); }
On device test i read thi alert:
Open database ERROR: code:0
but in console I can read 'DB opened: consiglinonna.db'
what does it means? what am I doing wrong?
please, please help me!!!
thanks
Lisa P. wrote:
Hi,
i have some problem to read a sqlLite db.
I add in my Intel xdk project the plugin cordova-sqlite-storage and i have add my .db file in www folder.
In index.html I use this code:
document.addEventListener("deviceready", onDeviceReady, false); function successCallback(db) { alert("successo : "+db); } function errorCallback(db) { alert("error : "+db); } function onDeviceReady() { var db = window.sqlitePlugin.openDatabase({name: "consiglinonna.db", createFromLocation: 1, androidLockWorkaround: 1}); //, function(db) { db.transaction(function(tx) { alert('ciao'); //tx.executeSql("SELECT * FROM 'categorie'", [], function(tx, res) { tx.executeSql("SELECT * FROM categorie", [], function(tx, res) { alert("res: " + JSON.stringify(res)); alert("res1: " + res.rows[0]); }, function(error) { alert('SELECT error: ' + error.message); }); }, function(err,a,b,c) { alert('Open database ERROR: ' + JSON.stringify(err)); // alert(err+"\n"+a+"\n"+b+"\n"+c); }); }On device test i read thi alert:
Open database ERROR: code:0but in console I can read 'DB opened: consiglinonna.db'
what does it means? what am I doing wrong?
please, please help me!!!
thanks
include "SQLitePlugin.js" to index.html
<script src="../plugins/cordova-sqlite-storage/www/SQLitePlugin.js"></script>
or you can check my simple project :
https://www.dropbox.com/s/2u1l4eh3x734h1m/intel_XDK_%28programsederhana%29.zip?dl=0
Hi,
thanks for your answer.
I add the js call in this way (src
=
"plugins/cordova-sqlite-storage/www/SQLitePlugin.js"), but notthing is change (Attention: i used 'plugins' and not '../plugins' because '../plugins' gives error that can't read the file...).
I think that the db is opened, but the select query (SELECT * from categorie) fail, because i can see the alert 'ciao', but not the alert 'res' and 'res1'.
I opened your project in my intel xdk yesterday but I think to have the same problem...in console I can read 'DB opened', but the table that prints the result is empty.
I add in your code some alert and data.rows.length il 0, like in my case...
function data_m(){
db_mahasiswa.transaction(function(tx) {
alert('pippo');
tx.executeSql("SELECT * FROM data_mahasiswa", null, function(tx, data) {
alert('pluto '+data.rows.length);
Sorry form my bad english...
Lisa P. wrote:
Hi,
thanks for your answer.
I add the js call in this way (src="plugins/cordova-sqlite-storage/www/SQLitePlugin.js"), but notthing is change (Attention: i used 'plugins' and not '../plugins' because '../plugins' gives error that can't read the file...).
I think that the db is opened, but the select query (SELECT * from categorie) fail, because i can see the alert 'ciao', but not the alert 'res' and 'res1'.
I opened your project in my intel xdk yesterday but I think to have the same problem...in console I can read 'DB opened', but the table that prints the result is empty.
I add in your code some alert and data.rows.length il 0, like in my case...
function data_m(){
db_mahasiswa.transaction(function(tx) {
alert('pippo');
tx.executeSql("SELECT * FROM data_mahasiswa", null, function(tx, data) {
alert('pluto '+data.rows.length);Sorry form my bad english...
Don't test application in emulator, it's not works,.. but you must try your application on your device,.,
I also had problems when I test the application in the emulator, but when I tried it on my device, it's worked,.,
Don't test application in emulator, it's not works,.. but you must try your application on your device,.,
I also had problems when I test the application in the emulator, but when I tried it on my device, it's worked,.,
Hi,
I tested always on my device connected with USB cable (emulator tab alert me "Unimplemented API Emulation").
Lisa P. wrote:no, that's not who I mean. but you must build your application & install your application on your device,.. not test with connected by usb,.. it's just like you test in the emulate,..
Hi,
I tested always on my device connected with USB cable (emulator tab alert me "Unimplemented API Emulation").
Exactly.
You always have to build and really install on the device. If you like, you can use googledrive, dropbox or other services like that to upload from the computer and download (and install) from the mobile.
Until now, no way to test in emulator
If you are having trouble getting the Debug tab to work, please see these pages:
On some devices you may have to start App Preview manually on the device before the Debug tab will work.
FWIW : I can confirm that this works when debugging from the XDK on an USB connected Android device - which obviously allows for faster testing than building the app/installing it on your device
(just wondering where the actual DB file is created on the device - but that's another issue)
posiblemente ya lo resolvieron, pero en este momento logre instalar el plugin desde la siguiente dirección:
https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free
Saludos,
I can not add plugin cordova-sqlite-storage because it exists this error:
Uh oh! "/media/destructor/Documents/Projects/IntelXDK/Temp/plugins/cordova-sqlite-storage/node_modules/cordova-sqlite-storage-dependencies/libs/sqlite-connector.jar" not found!
Are you using the git repo mentioned in the above comment to add the plugin in the way this article outlines for third-party plugins? >https://software.intel.com/en-us/xdk/docs/add-manage-project-plugins< this should provide a good step-by-step to adding it to your project. If you are not using the git repo option, how are you attempting to add it?
Роман Б. wrote:
I can not add plugin cordova-sqlite-storage because it exists this error:
Uh oh! "/media/destructor/Documents/Projects/IntelXDK/Temp/plugins/cordova-sqlite-storage/node_modules/cordova-sqlite-storage-dependencies/libs/sqlite-connector.jar" not found!
That plugin is not compatible with either the XDK cloud build system or with the PhoneGap Build system. It can only be used with Cordova CLI. This is due to the use of "hooks scripts" which is described in the README.md file > https://github.com/litehelpers/Cordova-sqlite-storage#status < and is directly related to the error you are seeing.
The last version of that plugin that can be used with the XDK or with PhoneGap Build is 1.2.2. After that release of the plugin the author added the "before_plugin_install" hooks script.
Community support is provided Monday to Friday. Other contact methods are available here.
Intel does not verify all solutions, including but not limited to any file transfers that may appear in this community. Accordingly, Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.
For more complete information about compiler optimizations, see our Optimization Notice.