0

I want to work with sqlite with cordova framework for the first time. As I've read on a tutorial I should use ngcordova like this:

  if (window.cordova)
     {
     db = $cordovaSQLite.openDB({ name: "littlebird.db" }); //device
     }
    else
     {
            db = window.openDatabase("littlebird.db", '1', 'littlebird', 1024 * 1024 * 100); // browser
     }

        $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS mobileContact (id integer primary key, name text, mobile text,exit integer)");

but facing issue while deployment

Uncaught TypeError: Cannot read property 'openDatabase' of undefined ng-cordova.min.js (9,20659)
4

1 Answer 1

0

Edit :

specifying the location solve the problem :

db = $cordovaSQLite.openDB({ name: "DBname.db" ,location:'?'});

(look in the comments of this answers post for more details. )

2
  • db = $cordovaSQLite.openDB({ name: "littlebird.db", location: 2, createFromLocation: 1 }); //device Sep 23, 2016 at 12:33
  • Great, Seems specifying the location solve the problem. Sep 25, 2016 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.