SQLite Porter


This Cordova/Phonegap plugin can be used to import/export to/from a SQLite database using either SQL or JSON.



If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.

Contact Us Today!

Ionic 数据库 SQLite Porter插件的安装(Installation)

ionic cordova plugin add uk.co.workingedge.cordova.plugin.sqliteporter npm install @ionic-native/sqlite-porter
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEY npm install @ionic-enterprise/sqlite-porter

Ionic 数据库 SQLite Porter插件支持的平台(Supported Platforms)

  • Amazon Fire OS
  • Android
  • BlackBerry 10
  • Browser
  • iOS
  • Tizen
  • Windows
  • Windows Phone

Ionic 数据库 SQLite Porter插件的用法(Usage)

import { SQLitePorter } from '@ionic-native/sqlite-porter/ngx';

constructor(private sqlitePorter: SQLitePorter) { }


let db = window.openDatabase('Test', '1.0', 'TestDB', 1 * 1024);
// or we can use SQLite plugin
// we will assume that we injected SQLite into this component as sqlite
  name: 'data.db',
  location: 'default'
  .then((db: any) => {
    let dbInstance = db._objectInstance;
    // we can pass db._objectInstance as the database option in all SQLitePorter methods

let sql = 'CREATE TABLE Artist ([Id] PRIMARY KEY, [Title]);' +
           'INSERT INTO Artist(Id,Title) VALUES ("1","Fred");';

this.sqlitePorter.importSqlToDb(db, sql)
  .then(() => console.log('Imported'))
  .catch(e => console.error(e));