DisyInformationssysteme / Cordova-spatialite-storage

A Cordova/PhoneGap plugin to open and use sqlite databases on Android/iOS/Windows Universal(8.1)/Amazon Fire-OS/WP(7/8) with HTML5/Web SQL API
Other
24 stars 17 forks source link

Get started with cordova-spatialite-storage #16

Open Alma9170 opened 4 years ago

Alma9170 commented 4 years ago

Hi, I am developing a cordova app for android working with spatial data. For processing spatial data I am trying to use cordova-spatialite-storage plugin. Following plugin's documentation, first of all, I added plugin to my project, then placed my Db.sqlite in my device (file:///storage/emulated/0/Download/DB.sqlite). at last, I executed a simple query as follows: query = 'SELECT Geometry FROM myTable LIMIT ?'; var args = [20]; var querySuccess = function(results) { } var queryError = function(error) { alert(error) } var spatialiteURI = "file:///storage/emulated/0/Download/DB.sqlite"; var db = window.sqlitePlugin.openDatabase({name: spatialiteURI}); db.transaction(function(tx) { tx.executeSql(query, args, querySuccess, queryError); })

But the only thing I've got is alert(error) in queryError function (please see attached picture). It's worth mentioning, I am using Framework7 as javascript framwork in my project.

Can you please help me what's wrong with my code?Thank you for any help you can offer.

20200516_001714

KimberleeDArmstrong commented 4 years ago

I was having the same problem. This version fixed it for me. Good Luck!

cordova plugin add https://github.com/DisyInformationssysteme/Cordova-spatialite-storage#06762c59b5bb6d8ee402dea64c942a4d84623cb9

Alma9170 commented 4 years ago

I was having the same problem. This version fixed it for me. Good Luck!

cordova plugin add https://github.com/DisyInformationssysteme/Cordova-spatialite-storage#06762c59b5bb6d8ee402dea64c942a4d84623cb9

thanks! I am using cordova-spatialite-storage version 2.0.0 (the latest version) but the plugin can't find my database file. I think there is something wrong with database name I am using in my code as follows: var spatialiteURI = "file:///storage/emulated/0/Documents/DB.sqlite"; var db = window.sqlitePlugin.openDatabase({ name: spatialiteURI });

In addition, In case I use a name like "DB.sqlite" the plugin will create a new database. Is my way of defining database name option wrong ?Or is there another way to do this? It is so critical for me to process spatial data in my app. So any help make this plugin work is so appreciated. Thanks in advance.