用命令提示符创建Sqlite数据库

1.首先新建项目,打开项目,运行程序。在data/data下面找到刚刚新建的项目。在新建的项目里面创建数据库。eg:com.example.111

2.找到SDK文件内的platform-tools

3.输入cmd进入命令提示符

4.命令提示符内代码

D:\Sdk\platform-tools>adb shell
//登录android设备的shell环境
root@generic_x86:/ # mkdir /data/data/com.example.111
mkdir failed for /data/data/com.example.111, File exists
255|root@generic_x86:/ # mkdir /data/data/com.example.111/database
//创建database文件夹
root@generic_x86:/ # cd /data/data/com.example.111/database
//进入database文件夹
root@generic_x86:/data/data/com.example.111/database # sqlite3 hhh
//创建数据库hhh
SQLite version 3.8.6 2014-08-15 11:46:33
Enter ".help" for usage hints.
sqlite> create table user
//创建user表
   ...> (id integer primary key autoincrement,
//id 为主键
   ...> name text not null,
//姓名
   ...> pwd text);
//密码
sqlite> .tables
user
sqlite> .schema
CREATE TABLE user
(id integer primary key autoincrement,
name text not null,
pwd text);
sqlite> insert into user values(1,'hst','123');
sqlite> insert into user values(2,'ly','456');
//添加
sqlite> select * from user;
//查询
1|hst|123
2|ly|456
sqlite>update user set id=5 where id=1;
//修改
sqlite>delete from user where id=2;
//删除

 5.创建数据库完成

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值