title: Create Database in SQLite with IONIC 3 + CORDOVA
body: <p>I am developing an app with SQLite that creates and lists users ...</p>
  
  <p><a href="https://i.stack.imgur.com/9LYmo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9LYmo.png" alt="Screenshot"></a></p>
  
  <p>For this I have created a service in which I create the database and two methods (create and list), it should be mentioned that there are no errors and I have imported everything correctly</p>
  
  <p>database.ts:</p>
  
  <pre><code>@Injectable()
  export class DatabaseProvider {
  
    private db: SQLiteObject;
    private isOpen: boolean;
  
    constructor(
      public http: Http,
      public storage: SQLite) {
  
        if(!this.isOpen){
          this.storage = new SQLite();
          this.storage.create({ name: "data.db", location:"default" }).then((db:SQLiteObject) =&gt; {
            this.db = db;
            db.executeSql("CREATE TABLE IF NOT EXIST usuarios (Codigo INTEGER PRIMARY KEY AUTOINCREMENT, Identificacion INTEGER, Nombre TEXT, Apellido TEXT)", []);
            this.isOpen = true;
          }).catch((error) =&gt; {
            console.log(error);
          })
        }
        }
  
  crearUsuario(Identificacion:number, Nombre:string, Apellido:string){
    return new Promise ((resolve , reject) =&gt; {
      let sql = "INSERT INTO usuarios (Identificacion, Nombre, Apellido) VALUES (?, ?, ?)";
      this.db.executeSql(sql, [Identificacion, Nombre, Apellido]).then((data) =&gt; {
        resolve(data);
      }, (error) =&gt; {
        reject(error);
      });  
    });
  }
  
  listarUsuario(){
    return new Promise ((resolve , reject) =&gt; {
      this.db.executeSql("SELECT * FROM usuarios", []).then((data) =&gt; {
        let arrayUsuarios = [];
        if(data.rows.length &gt; 0){
          for (var i=0; i &lt; data.rows.length; i++){
            arrayUsuarios.push({
              Codigo: data.rows.item(i).Codigo,
              Identificacion: data.rows.item(i).Identificacion,
              Nombre: data.rows.item(i).Nombre,
              Apellido: data.rows.item(i).Apellido,
            });
          }
        }
        resolve(arrayUsuarios);
      }, (error) =&gt; {
        reject(error);
      })
    });
  }
  
  }
  </code></pre>
  
  <p>in my view home.html I have a form and two buttons ... one lists the users and the other creates the users of the form</p>
  
  <p>home.html:</p>
  
  <pre><code>&lt;button ion-button block color="secondary" (click)="listarUsuario()"&gt;Listar Usuario&lt;/button&gt;
  
  &lt;form [formGroup]="todo" (ngSubmit)="crearUsuario()" novalidate&gt;
    &lt;ion-item&gt;
      &lt;ion-label&gt;Nombre&lt;/ion-label&gt;
      &lt;ion-input type="text" formControlName="Nombre"&gt;&lt;/ion-input&gt;
    &lt;/ion-item&gt;
    &lt;ion-item *ngIf="todo.get('Nombre').errors &amp;&amp; todo.get('Nombre').dirty"&gt;     
    &lt;/ion-item&gt;
    &lt;ion-item&gt;
      &lt;ion-label&gt;Apellido&lt;/ion-label&gt;
      &lt;ion-input type="text" formControlName="Apellido"&gt;&lt;/ion-input&gt;
    &lt;/ion-item&gt;
    &lt;ion-item *ngIf="todo.get('Apellido').errors &amp;&amp; todo.get('Apellido').dirty"&gt;      
    &lt;/ion-item&gt;
    &lt;ion-item&gt;
      &lt;ion-label&gt;Indentificación&lt;/ion-label&gt;
      &lt;ion-input type="text" formControlName="Identificacion"&gt;&lt;/ion-input&gt;
    &lt;/ion-item&gt;
    &lt;button ion-button block type="submit" [disabled]="!todo.valid"&gt;Crear Usuario&lt;/button&gt;
  &lt;/form&gt;
  
  &lt;ion-list&gt;
    &lt;ion-item-sliding *ngFor="let item of listaPersonas"&gt;
      &lt;ion-item&gt;      
        &lt;h2&gt;{{item.Nombre}} - {{item.Apellido}}&lt;/h2&gt;     
      &lt;/ion-item&gt;   
      &lt;ion-item-options side="right"&gt;
        &lt;button ion-button color="danger"&gt;
          &lt;ion-icon name="delete"&gt;&lt;/ion-icon&gt;
          Eliminar
        &lt;/button&gt;
      &lt;/ion-item-options&gt; 
    &lt;/ion-item-sliding&gt;
  &lt;/ion-list&gt;
  </code></pre>
  
  <p>my controller has the following code:</p>
  
  <p>home.ts:</p>
  
  <pre><code>export class HomePage {
  
    private listaPersonas: any;
    private todo: FormGroup;
  
    constructor(public navCtrl: NavController, private database: DatabaseProvider, private formBuilder: FormBuilder) {
  
      this.todo = this.formBuilder.group({
        Nombre: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(8)]],
        Apellido: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(8)]],
        Identificacion: ['', Validators.required],
      });
  
    } 
  
    crearUsuario(){
      console.log(this.todo);
  
        this.database.crearUsuario(this.todo.value.Identificacion, this.todo.value.Nombre, this.todo.value.Apellido).then((data) =&gt; {
          console.log(data);
          this.listarUsuario();
        }, (error) =&gt; {
          console.log(error);
        }) 
      }
  
    listarUsuario(){
      this.database.listarUsuario().then((data: any) =&gt; {
        console.log(data);
        this.listaPersonas = data;
      }, (error) =&gt; {
        console.log(error);
      })
    }    
  
  }
  </code></pre>
  
  <p>I'm testing my application on a physical device, but it does not do anything ... do not create, do not list users, I guess I'm not creating the database, I'm new to IONIC 3 and to deploy my application on the physical device first I build with the command <code>ionic cordova build android</code> and then I deploy my app on the phone with the command <code>ionic cordova run android --device</code></p>
  
  <p>what am I doing wrong? How can I find the error by trying my app on a physical device? with my debugging console? where is the Ionic 3 database physically stored in my device (directory)? any help for me?</p>