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

Problems on create database in Android #3

Closed WilliamCesarSantos closed 7 years ago

WilliamCesarSantos commented 7 years ago

Hi, i use this plugin and SQLCipher(https://github.com/litehelpers/Cordova-sqlcipher-adapter) in Android app, but, when it's tempted create new database in app, an error occurs, description of error: java.illegalargument.exception: URI is not absolute. Creation of the database is in this way window.sqlitePlugin.openDatabase({name: 'database1.db', key: '123', location: 'default', androidLockWorkaround: 1},success,error); I used Promise

Cultrarius commented 7 years ago

Hey, see also Issue https://github.com/DisyInformationssysteme/Cordova-spatialite-storage/issues/2, this plugin does not create new databases on its own. It can only be used to open existing databases. Also, you should not use name: 'database1.db', but always an absolute file path.

Do you use SQLCipher and our Spatialite plugin to access the same database file? Because that is not recommended and can corrupt your database.

WilliamCesarSantos commented 7 years ago

Hi, Cultrarius, I had tempted use same database for Sqlcipher and Spatialite, but isn't not possible, because this problem. Removed Spatialite temporarily. I will use two database in future, one SqlCipher and other to Spatialite, thanks for response.

Alma9170 commented 4 years ago

Hey, see also Issue #2, this plugin does not create new databases on its own. It can only be used to open existing databases. Also, you should not use name: 'database1.db', but always an absolute file path.

Do you use SQLCipher and our Spatialite plugin to access the same database file? Because that is not recommended and can corrupt your database.

Hello, I am using cordova-spatialite-storage version 2.0.0, and the way I use the database is like this: try { var query = 'SELECT Geometry From '; var args = []; var querySuccess = function (results) { alert(results) } var queryError = function (error) { alert(error.toString()) } var spatialiteURI = "file:///storage/emulated/0/Documents/DB.sqlite"; var db = window.sqlitePlugin.openDatabase({ name: spatialiteURI }); db.transaction(function (tx) { tx.executeSql(query, args, querySuccess, queryError); }); } catch (ex) { alert(ex.message) } But this code is not working and the plugin can't find my database file. I think there is something wrong with URI I am using. thank you in advance for your help.