After upgrading to RC3, I can’t seem to open a Sqlite database.
After playing with it for a while in my app, I created a new app, installed cordova-sqlite-storage, and entered the following code into app.component.ts:
import { Component } from ‘@angular/core’;
import { Platform } from ‘ionic-angular’;
import { StatusBar, Splashscreen, SQLite } from ‘ionic-native’;
import { TabsPage } from ‘…/pages/tabs/tabs’;
@Component({
templateUrl: ‘app.html’
})
export class MyApp {
rootPage = TabsPage;
constructor(platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
Splashscreen.hide();
let db = new SQLite(); db.openDatabase({ name: "data.db", location: "default" }).then(() => { db.executeSql("CREATE TABLE IF NOT EXISTS people (id INTEGER PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT)", {}).then((data) => { console.log("TABLE CREATED: ", data); }, (error) => { console.error("Unable to execute sql", error); }) }, (error) => { console.error("Unable to open database", error); }); });
}
}
This was based on this tutorial, which, admittedly is pre-RC3.
On running the app on the emulator, I get: “console.error: Unable to open database {“line”:76,“column”:25}”
Is anyone else having trouble with the Sqlite Plugin? Suggestions?