Android SQlite Problem


Hi there,
im trying to implement $cordovaSQLite and open the database. Unfortunately it won’t work (sayed it cannot open the database).

My code:
var login = angular.module("login", ["ionic", 'ngCordova']) .run(function ($ionicPlatform, $cordovaSQLite) { $ionicPlatform.ready(function () { if (window.cordova && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); } if (window.StatusBar) { StatusBar.styleDefault(); } db = $cordovaSQLite.openDB({name : "my.db"}); $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people (id integer primary key, firstname text, lastname text)"); }); })

Logcat prints the following error message:

[INFO:CONSOLE(174)] “OPEN database: my.db”, source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (174)

[INFO:CONSOLE(195)] “OPEN database: my.db failed, aborting any pending transactions”, source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (195)

[INFO:CONSOLE(82)] “Could not open database”, source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (82)

Can anybody help me with this?




did you added the sqlite cordova plugin first?


yes i did but it it seems like it just wont work :confused:


You probably are missing the third parameter

db = $cordovaSQLite.openDB({name : "my.db"});
var query = "CREATE TABLE IF NOT EXISTS people (id integer primary key, firstname text)
$cordovaSQLite.execute(db, query, []).then(function(res) {
}, function (err) {

If you want to test it also in your browser check this out:
Let me know if it hepls!


if you are not using any prepared params the last parameter can be omitted.
could you remove the table creation code? --> only try to oopen your database.

Does the error also occurs?


Thank @gianfra_ for your reply,
i tried your code and undortunatly, it won’t call either the success nor the error callbacks :confused:


Hi @bengtler,
i tried your advice and the error is still alive.
Could it maybe be a thing of permissions? I tried to grant every possible permission in the AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE" />


Thanks to @bengtler and @gianfra_ for your help,
finally i found the problem (and i dont know why it work in that way, because in all tutorials they do it different).

My problem was that i include the “ng-cordova.min.js” before i include the “cordova.js” file (how i saw in the tutorial).

Unfortunately my Logcat doesnt displayed the errors, that it could not find angularjs. Just when i created a seperate project and tried it with it, it displayed me the error messages and i could correct it.

Thanks for your help,



nice you got it working!

and letting us know, that you solved your problem :blush:


Thanks a lot for providing your solution :slight_smile:


I’m having the same issue here. I made a question at

I tried putting the .min script before and after cordova.js but no luck. Also tried with the android manifest xml.
The thing is that this was working 4 days ago and I don’t know what happened.

Thanks in advance!