Last active
June 16, 2017 06:50
-
-
Save nikhildhar1992/fb7bdeac9d20a0e17a599a25042ce15d to your computer and use it in GitHub Desktop.
Sqlite in this is not working when I run ionic cordova run android -l -s -s but when I run ionic cordova run android it will work why this difference ??
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { ErrorHandler, NgModule } from '@angular/core'; | |
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; | |
import { SplashScreen } from '@ionic-native/splash-screen'; | |
import { StatusBar } from '@ionic-native/status-bar'; | |
import { SQLite } from '@ionic-native/sqlite'; | |
import { MyApp } from './app.component'; | |
import { HomePage } from '../pages/home/home'; | |
import { SqliteProvider } from '../providers/sqlite/sqlite'; | |
@NgModule({ | |
declarations: [ | |
MyApp, | |
HomePage | |
], | |
imports: [ | |
BrowserModule, | |
IonicModule.forRoot(MyApp) | |
], | |
bootstrap: [IonicApp], | |
entryComponents: [ | |
MyApp, | |
HomePage | |
], | |
providers: [ | |
StatusBar, | |
SplashScreen, | |
{provide: ErrorHandler, useClass: IonicErrorHandler}, | |
SqliteProvider, | |
SQLite | |
] | |
}) | |
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { SqliteProvider } from '../../providers/sqlite/sqlite'; | |
//import {ColorPickerModule} from 'ngx-color-picker'; | |
@Component({ | |
selector: 'page-home', | |
templateUrl: 'home.html', | |
//providers: [SqliteProvider], public sqliteP: SqliteProvider | |
}) | |
export class HomePage { | |
public image: any; | |
private color; | |
constructor(public sqliteP: SqliteProvider) | |
{ | |
sqliteP.insert("nikhil"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { SQLite, SQLiteObject } from '@ionic-native/sqlite'; | |
import 'rxjs/add/operator/map'; | |
@Injectable() | |
export class SqliteProvider { | |
private db1: SQLiteObject; | |
public sellData: Array<Object>; | |
constructor(private db: SQLite) { | |
this.db = new SQLite(); | |
this.db.create({ | |
name: 'data.db', | |
location: 'default' | |
}).then((dbObj:SQLiteObject) => { | |
this.db1 = dbObj; | |
this.createTable(); | |
}); | |
} | |
public createTable() { | |
this.db1.executeSql('create table if not exists tempTable (path Long Text', {}) | |
.then((data) => { | |
}).catch(e => alert(e)); | |
} | |
public insert(path: string) { | |
setTimeout(function(){ | |
this.db1.executeSql('insert into tempTable(path ) values ("' + path + '")', {}) | |
.then((data) => { | |
alert(data); | |
}).catch(e => alert("insert catch")); | |
},2000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment