Error with Sqlite db

hai i am using sqlite db .I have created a db service as described in this link.but it shows an error
" Cannot call method ‘transaction’ of null" on self.db.transaction(function (transaction ".I am calling the init() function in $ionicPlatform ready.but db is showing as null.can anyone help how to fix that??

I don’t know exactly why but if you are using new Cordova you need to specify location of SQLite DB. So you just need to pass location='default' to DB init function.

my issue does not shows when i called the init function before performing any db change.I have called db.init() in $ionicPlatform why does it requires repeated db.init??


where to pass location=‘default’

my init function is like this

var self = this;
self.db = null;

self.init =function(){
	  var def = $q.defer();
		    if (window.cordova) {
    	      self.db = $cordovaSQLite.openDB({name: "demo.db"},function(){
    	    	  console.log("created SQlite DB");
    	    	self.db = window.openDatabase("demo.db", '1', 'demo', 1024 * 1024 * 100); // browser
	  return def.promise;

should be:
$cordovaSQLite.openDB({name: “demo.db”, location: “default”}

As for init i don’t know, i don’t use ngCordova for SQLite.

1 Like

$cordovaSQLite.openDB({name: “demo.db”, location: “default”}

this worked…Thanks