Cordova-plugin-sqlite could not open database on Android

Hi there,

customer told me, the app I wrote does not work on his Android 5.1 tablet. After logcatting the app I see following in the console:

[INFO:CONSOLE(171)] "OPEN database: myDB.db", source: file:///android_asset/www/plugins/cordova-plugin-sqlite/www/SQLitePlugin.js (171)
[INFO:CONSOLE(102)] "new transaction is waiting for open operation", source: file:///android_asset/www/plugins/cordova-plugin-sqlite/www/SQLitePlugin.js (102)
[INFO:CONSOLE(192)] "OPEN database: myDB.db failed, aborting any pending transactions", source: file:///android_asset/www/plugins/cordova-plugin-sqlite/www/SQLitePlugin.js (192)
[INFO:CONSOLE(79)] "Could not open database", source: file:///android_asset/www/plugins/cordova-plugin-sqlite/www/SQLitePlugin.js (79)

Any clues, why this is happening? In the past on other test drives I saw a similar error message. I just reinstalled the cordova-plugin-sqlite 1.0.3 ( ) and the error was gone. But this time simple reinstallation is not the answer. So why can’t it open the DB?

The versions I use:
Ionic 1.7.14
Cordova 6.1.1
Bower 1.7.9
npm 2.11.3

It sounds like an issue with not checking for platform ready,

ionic.Platform.ready(function() {
  // your db code.


$ionicPlatform.ready(function() { 
  // your db code.

There are a few posts that talk about it here in the forum.

Thanks A_Burgess. I allready use the ionic.Platform.ready() method, but it still seems not working.

Is there a difference between $ionicPlatform.ready() and ionic.Platform.ready()?

Also I will check the “low-level” version of the ready event handling with document.addEventListener('deviceready', function() { ... });

I’ll report the results later. If anyone has more clues why the database does not open, please feel free to write it down here :slight_smile:

No difference as far as I understand it.

No difference … no solution for the database problem.

I’m still struggling with this issue. Device-Ready-Events are fired correctly. Still cannot open the database on an Android 5 tablet. But it works on Android 5 smartphones … so what’s going on here?

I confirm: $ionicPlatform.ready() and ionic.Platform.ready() will be called BEFORE document.addEventListener('deviceready', function() { ... });.

So I thought: Okay, then I’ll move the opening routines for my database to the event handler …

… Still same problem. The database cannot be opened.