Ionic 2 is today one of the most popular open source and free hybrid mobile framework for build hybrid mobile apps for Android ,iOS and even Windows Universal Platform .
Installation :-
- Install the Cordova and Ionic Native plugins:
- $ ionic cordova plugin add cordova-sqlite-storage
- $ npm install –save @ionic-native/sqlite
import sqlite from ionic-native :
import { SQLite, SQLiteObject } from ‘@ionic-native/sqlite’;
Use "private sqlite: SQLite" in constructor :
constructor(private sqlite: SQLite) {
this.sqlite.create({
name: ‘data.db’,
location: ‘default’
})
.then((db: SQLiteObject) => {
db.executeSql(‘create table user(name VARCHAR(32))’, {})
.then(() => console.log(‘Executed SQL’))
.catch(e => console.log(e));
})
.catch(e => console.log(e));
}
No comments:
Post a Comment