title: I ain't able to open db in cordova-sqlite-storage for ionic 1
body: <p>I am new in ionic 1 and are having a lot of problems to create a database in sqlite storage. Could you help me?</p>
  
  <p>I am using the plugin with the name above, 'cordova-sqlite-storage'
  The problem is, when the code pass in the openDB command it stop in there and aren't able to proceed.</p>
  
  <p>Follow my code:</p>
  
  <p>js/sqlite.js</p>
  
  <pre><code>var sqlite = angular.module('sqlite', ['ionic', 'ngCordova']);
  
  sqlite.run(function ($ionicPlatform, $cordovaSQLite) {
      $ionicPlatform.ready(function () {
          var db = $cordovaSQLite.openDB({ name: "rollers.db", bgType: 1 });
          $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS clientes (id integer primary key, razaoSocial varchar(40), nomeFantasia varchar(40), CNPJ text, Endereco text)");
          $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS instalacao (id integer primary key, idCliente int, DataInst datetime)");
          $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS manutencao (id integer primary key, idCliente int, idInstalacao int, DataManut datetime)");
          $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS equipamento (id integer primary key, idInstalacao int, idManutencao int, TC int, Rolo varchar(40))");
      });
  })
  
  sqlite.factory('clientesFactory', function ($cordovaSQLite) {
      return {
          insert: function (firstname, lastname, avatar, message) {
              var query = "INSERT INTO clientes    (razaoSocial, nomeFantasia, CNPJ, Endereco) VALUES (?, ?, ?, ?);";
              var values = [firstname, lastname, avatar, message];
  
              $cordovaSQLite.execute(db, query, values).then(
                function (res) {
                    console.log('INSERTED ID: ' + res.insertId);
                },
                function (err) {
                    console.log('ERROR: ' + err);
                }
              );
          },
  
          insertInstalacao: function (idCliente, DataInst) {
              var query = "INSERT INTO instalacao  (idCliente, DataInst) VALUES (?, ?);";
              var values = [idCliente, DataInst];
  
              $cordovaSQLite.execute(db, query, values).then(
                function (res) {
                    console.log('INSERTED ID: ' + res.insertId);
                },
                function (err) {
                    console.log('ERROR: ' + err);
                }
              );
          },
  
          insertInstalacao: function (idCliente, idInstalacao, DataManut) {
              var query = "INSERT INTO manutencao  (idCliente, idInstalacao, DataManut) VALUES (?, ?, ?, ?);";
              var values = [idCliente, idInstalacao, DataManut];
  
              $cordovaSQLite.execute(db, query, values).then(
                function (res) {
                    console.log('INSERTED ID: ' + res.insertId);
                },
                function (err) {
                    console.log('ERROR: ' + err);
                }
              );
          },
  
          insertInstalacao: function (idInstalacao, idManutencao, TC, Rolo) {
              var query = "INSERT INTO equipamento (idInstalacao, idManutencao, TC, Rolo) VALUES (?, ?, ?, ?);";
              var values = [idInstalacao, idManutencao, TC, Rolo];
  
              $cordovaSQLite.execute(db, query, values).then(
                function (res) {
                    console.log('INSERTED ID: ' + res.insertId);
                },
                function (err) {
                    console.log('ERROR: ' + err);
                }
              );
          },
  
          select: function (id) {
              var query = "SELECT * FROM clientes WHERE id=?";
              var values = [id];
  
              $cordovaSQLite.execute(db, query, values).then(
                function (res) {
                    if (res.rows.length &gt; 0) {
                        var first = res.rows.item(0);
                        console.log(res.rows.length + ' records, fist: ' + first.firstname + ' ' + first.lastname + ' - ' + first.avatar);
                    } else {
                        console.log('No records found');
                    }
                }
              );
          }
      }
  });
  </code></pre>
  
  <p>index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"&gt;
      &lt;title&gt;&lt;/title&gt;
  
      &lt;link href="lib/ionic/css/ionic.css" rel="stylesheet"&gt;
      &lt;link href="css/style.css" rel="stylesheet"&gt;
  
      &lt;!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
      &lt;link href="css/ionic.app.css" rel="stylesheet"&gt;
      --&gt;
  
      &lt;!--For users deploying their apps to Windows 8.1 or Android Gingerbread, platformOverrided.js
      will inject platform-specific code from the /merges folder --&gt;
      &lt;script src="js/platformOverrides.js"&gt;&lt;/script&gt;
  
      &lt;!-- ionic/angularjs js --&gt;
      &lt;script src="lib/ionic/js/ionic.bundle.js"&gt;&lt;/script&gt;
      &lt;script src="lib/ngCordova/dist/ng-cordova.js"&gt;&lt;/script&gt;
  
      &lt;!-- cordova script (this will be a 404 during development) --&gt;
      &lt;script src="cordova.js"&gt;&lt;/script&gt;
  
      &lt;!-- your app's js --&gt;
      &lt;script src="js/sqlite.js"&gt;&lt;/script&gt;
      &lt;script src="js/app.js"&gt;&lt;/script&gt;
      &lt;script src="js/controllers.js"&gt;&lt;/script&gt;
      &lt;script src="js/services.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body ng-app="starter"&gt;
      &lt;ion-nav-view&gt;&lt;/ion-nav-view&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>js/controller.js:</p>
  
  <pre><code>.controller('ClienteDetalheCtrl', function ($scope, clientesFactory) {
  //.controller('ClienteDetalheCtrl', function ($scope){
      $scope.gravaCliente = function () {
          var primeiro_nome   = document.getElementById('TxtRazao').value;
          var segundo_nome    = document.getElementById('TxtFantasia').value;
          var avatar          = document.getElementById('TxtCNPJ').value;
          var mensagem        = document.getElementById('TxtEnd').value;
          clientesFactory.insert(primeiro_nome, segundo_nome, avatar, mensagem);
          clientesFactory.select(1);
          document.getElementById('TxtRazao').value = 'teste';
      }
  
      $scope.limpaCliente = function () {
          document.getElementById('TxtRazao').value = '';
          document.getElementById('TxtFantasia').value = '';
          document.getElementById('TxtCNPJ').value = '';
          document.getElementById('TxtEnd').value = '';
      }
  })
  </code></pre>
  
  <p>app.js:</p>
  
  <pre><code>// Ionic Starter App
  
  // angular.module is a global place for creating, registering and retrieving Angular modules
  // 'starter' is the name of this angular module example (also set in a &lt;body&gt; attribute in index.html)
  // the 2nd parameter is an array of 'requires'
  // 'starter.services' is found in services.js
  // 'starter.controllers' is found in controllers.js
  SLAVE_AAPT_TIMEOUT = 30
  angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'sqlite'])
  //angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
  
  .run(function ($ionicPlatform) {
      $ionicPlatform.ready(function () {
          // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
          // for form inputs)
          if (cordova.platformId === "ios" &amp;&amp; window.cordova &amp;&amp; window.cordova.plugins &amp;&amp; window.cordova.plugins.Keyboard) {
              cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
              cordova.plugins.Keyboard.disableScroll(true);
  
          }
          if (window.StatusBar) {
              // org.apache.cordova.statusbar required
              StatusBar.styleDefault();
          }
      });
  })
  
  .config(function ($stateProvider, $urlRouterProvider) {
  
      // Ionic uses AngularUI Router which uses the concept of states
      // Learn more here: https://github.com/angular-ui/ui-router
      // Set up the various states which the app can be in.
      // Each state's controller can be found in controllers.js
      $stateProvider
  
      // setup an abstract state for the tabs directive
        .state('tab', {
            url: '/tab',
            abstract: true,
            templateUrl: 'templates/tabs.html'
        })
  
      // Each tab has its own nav history stack:
  
      .state('tab.home', {
          url: '/dash',
          views: {
              'tab-home': {
                  templateUrl: 'templates/home.html',
                  controller: 'HomeCtrl'
              }
          }
      })
  
      .state('tab.manutencao', {
          url: '/manutencao',
          views: {
              'tab-manutencao': {
                  templateUrl: 'templates/manutencao.html',
                  controller: 'InstalacaoCtrl'
              }
          }
      })
  
      .state('tab.instalacao', {
          url: '/instalacao',
          views: {
              'tab-instalacao': {
                  templateUrl: 'templates/instalacao.html',
                  controller: 'InstalacaoCtrl'
              }
          }
      })
  
      .state('tab.instalacao-detalhe', {
          url: '/instalacao-detalhe',
          views: {
              'tab-instalacao-detalhe': {
                  templateUrl: 'templates/instalacao-detalhe.html',
                  controller: 'InstalacaoDetalheCtrl'
              }
          }
      })
  
      .state('tab.cliente', {
          url: '/cliente',
          views: {
              'tab-cliente': {
                  templateUrl: 'templates/cliente.html',
                  controller: 'ClienteCtrl'
              }
          }
      })
  
      .state('tab.cliente-detalhe', {
          url: '/cliente-detalhe',
          views: {
              'tab-cliente-detalhe': {
              templateUrl: 'templates/cliente-detalhe.html',
              controller: 'ClienteDetalheCtrl'
              }
          }
      });
  
      // if none of the above states are matched, use this as the fallback
      $urlRouterProvider.otherwise('/tab/dash');
  
  });
  </code></pre>
  
  <p>If you everyone, could help me i would stay really grateful.</p>
  
  <p>Thank you for your attention.</p>