sqlite数据库连接方法

part1

  1. /****************第一步 命令行安装*******************/
  2. //在命令行中进入项目目录 输入下面进行安装
  3. ionic cordova plugin add cordova-sqlite-storage
  4. npm install --save @ionic-native/sqlite
  5. /****************第二步 加入到代码中*******************/
  6. //在 ./src/app/app.module.ts 中添加
  7. import {SQLite} from "@ionic-native/sqlite";
  8. //在 provides 中添加
  9. SQLite,
  10. /****************第三步 模块中*******************/
  11. //在要使用的模块中添加
  12. import {SQLite,SQLiteObject} from "@ionic-native/sqlite";
  13. //在constructor中加入
  14. private sqlite: SQLite
  15. //在代码中使用
  16. this.sqlite......

part2

/*************链接sqlite数据库***************/
this.sqlite.create({name: 'cheshiname.db',location: 'default'}).then(
(db: SQLiteObject) => {
this.myAppDatabase = db;
}
).catch(
e =>this.dd='写入数据库失败2'
);
/*************分析***************/
name ---- 数据库名称
location ---- 链接地址
then() ---- 链接成功返回值
catch() ---- 链接失败返回值
db ---- 链接对象

转载于:https://www.cnblogs.com/fnms/p/9051722.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值