Configure Cordova SQLite Storage

Posted on

Question :

I am not able to configure the Cordova SQLite Storage plugin. The steps I follow are:

  • Install the plugin with phonegap plugin add
  • Copy SQLitePlugin.js from within the plugin folder.
  • I configured the following permissions:
  • AndroidManifest.xml :

    <uses-permission android_name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android_name="android.permission.WRITE_EXTERNAL_STORAGE" />

    Then I’ll make the call:

    var db = window.sqlitePlugin.openDatabase({name: "my.db", location: 1});

    There you give an error, stating that you are not reporting that the database could not be opened. I do not know if any configuration is missing.

    Has anyone ever been through anything like this?


    Answer :

    A little late for an answer but maybe it helps.
    If you are trying to run the application in the browser it will not work.
    You need to run the application on your phone and debug the chrome.

    cordova run android -1

    and in chrome access


    On the Plugin site it indicates that the function to be used is sqlitePlugin.openDatabase () without the window in front.
    Another point is that this flame only works after the deviceready () event.

    As far as I understand in the documentation you have to create a sqllite file in another application like SQLliteBrowser and put the file created in the www directory.

    I have the environment installed on my machine and tried to replicate the example you passed, and despite all the above attempts I am also having the same error, which could indicate a Bug in the Plugin.


    Leave a Reply

    Your email address will not be published. Required fields are marked *