2017-03-16 87 views
1

我正在開發一個Ionic2應用程序。我使用的是Ionic STORAGE,它在android中使用SQLITE。我想要預覽該數據庫進行調試。我怎樣才能做到這一點。 android studio中的DDMS什麼也沒有顯示。如何在ionic2應用程序中預覽SQLITE數據庫

我聽說Stetho適合android應用程序調試。但找不到任何教程如何將它與Ionic2集成。

任何幫助,將不勝感激。

RGDS

回答

0

使用的WebSQL進行調試:

import { Injectable } from ''; 
import { SQLite } from 'ionic-native'; 
import { Platform } from 'ionic-angular'; 

const DB_NAME: string = 'particulars.db'; 
const win: any = window; 

@Injectable() 
export class StorageService { 

private _db: any; 
constructor(private platform: Platform) { 
    if (this.platform.is('cordova')) { 
    this._db = new SQLite(); 
    this._db.openDatabase({ 
    name: DB_NAME, 
    location: 'default' // the location field is required 
    }).then(() => { 
    this._tryInit(); 
    }); 
    } else { 
    console.warn('Storage: SQLite plugin not installed, falling back to WebSQL. Make sure to install cordova-sqlite-storage in production!'); 
    this._db = win.openDatabase(DB_NAME, '1.0', 'database', 5 * 1024 * 1024); 
    this._tryInit(); 
    } 

    _tryInit() { 
    //do query here 
    } 
} 

https://gist.github.com/NickStemerdink/64c782807fc31b7bc9b529ad4b1d56d5