Search code examples
androidionic-frameworkphonegap-pluginscordova-pluginsspatialite

Cordova spatialite database for android not working


I am am trying to use spatialite plugin from https://github.com/DisyInformationssysteme/Cordova-spatialite-storage

for my cordova application,

but the problem is that when i try to create database it shows me

Database open failed, aborting any pending transaction.

I dig a lot for alternative solution for using spatial feature, but unfortunately couldn't succeed.


Solution

  • We had the same problem but it looks like we managed to find a workaround. It seems that Cordova-spatialite-storage plugin has some issues with opening/creating a database if database does not already exist. If database exists, you should be fine but only if you also added cordova-plugin-file plugin.

    Try these steps:

    1. copy existing spatialite database to device (e.g. file:///storage/emulated/0/Download/database.sqlite - just for the sake of testing, later you should move it to more appropriate location)
    2. add cordova-plugin-file plugin
    3. check if cordova-plugin-compat plugin is also added
    4. add cordova-spatialite-storage plugin

    Try to open database with name: 'file:///storage/emulated/0/Download/database.sqlite' and run some spatial queries. It should work. Please let me know how it went.