Configure Cordova Sqlite Storage

Asked

Viewed 2,413 times

4

I am unable to configure the plugin Cordova Sqlite Storage. The steps I follow are:

  1. Install the plugin with phonegap plugin add https://github.com/litehelpers/Cordova-sqlite-storage
  2. Copy Sqliteplugin.js from inside the plugin folder.
  3. Configure 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 make the call:

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

There is error, stating that not stating that it was not possible to open the database. I do not know if any configuration is missing.

Has anyone there ever been through anything like that?

2 answers

1

A little late for an answer, but it might help. If you are trying to run the application in the browser it will not work. You need to run the application on mobile and debug Chrome.

cordova run android -1

and in Chrome access chrome://inspect

0

On the Plugin website 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 event deviceready().

As far as I understood in the documentation you have to create a sqllite file in another application like Sqllitebrowser and put the created file 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.

  • I continue with the same mistake. Anyway, thank you Vitor.

  • Any progress? with more data we can try to answer the question better.

  • I got Vitor. I installed the plugin by the CLI tool and managed the apk. The problem is that the plugin does not work in phonegap Developer, only generating the same apk. I’ve uploaded the test project example to https://github.com/markosbarbosa/exemplo-sqliteplugin If you’d like to suggest something, feel free. Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.