Ionic SQLite not working since new native update


#1

Since the update and changes to the Ionic native plugins, I cant get SQLite to work.

For testing puproses I created a new blank Ionic 2 app, installed the correct plugins using

$ ionic plugin add cordova-sqlite-storage
$ npm install --save @ionic-native/sqlite

after that I tried to create a new blank page and start the database:

import { Component } from '@angular/core';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

    constructor(private sqlite: SQLite) {
        this.sqlite.create({
            name: 'data.db',
            location: 'default'
        })
        .then((db: SQLiteObject) => {
            db.executeSql('create table danceMoves(name VARCHAR(32))', {})
            .then(() => console.log('Executed SQL'))
            .catch(e => console.log(e));
        })
        .catch(e => console.log(e));
    }
}

Unfortunately I get the error:
Error in ./MyApp class MyApp - inline template:0:0 caused by: No provider for SQLite!

I get the same error in my main app, anyone got any ideas?


#2

As per the Ionic Native docs ( http://ionicframework.com/docs/native/ ) you need to add SQLite to providers in your all’s NGModule.


#3

Yeah! Thanks alot for the help!


#4

A post was split to a new topic: How you implement sqlite native in your application