Android(安卓)订餐APP(Sqlite数据库,完整的增删改查)
一.背景
首先说说项目的背景,基于地铁口鸡蛋饼的一个小项目,APP中固定设置的鸡蛋饼搭配,顾客也可以自己搭配
二.开发环境
- AndroidStudio3.0.1
- JDK1.8
- 语言:JAVA
- 数据存储:Sqlite
三.功能
- 注册、登录、管理员、普通用户
- 首页:鸡蛋饼食材搭配
- 订单:购买订单展示
- 个人/管理:个人信息、用户信息、机器信息、订单管理、食材管理、退出登录等
- 技术知识:Sqlite增删改查、glide图片加载、Spinner、EventBus、butterknife等等
四.功能图
五.Sqlite数据库存储(增删改查)
字段值 | 数据类型 | 说明 |
id | text | 主键值 |
nickName | text | 用户名 |
password | text | 密码 |
path | text | 头像 |
qianming | text | 签名 |
phone | text | 手机号 |
birthday | text | 生日 |
sex | text | 性别 |
type | text | 用户类型 |
用户表
代码如下:
public class DbSqliteHelper extends SQLiteOpenHelper {
public DbSqliteHelper(Context ctx) {
super(ctx, "JianBin", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
//用户数据表
db.execSQL("CREATE TABLE if not exists user(id integer PRIMARY KEY autoincrement,"
+ " nickName text, password text, path text, qianming text, phone text, birthday text, sex text, beizhu text,type text)");
//鸡蛋饼订单信息数据表
db.execSQL("CREATE TABLE if not exists jiqidingdan(id integer PRIMARY KEY autoincrement,"
+ "dingdanbianhao text,userNmae text, binName text, lajiao text, salajiang text, fanqie text, zuoliao text, xiangcong text, bianhao text, price text, shuliang text, time text,zhuangtai text,huitui text,wanzi text,jidan text)");
db.execSQL("CREATE TABLE if not exists jiqibin(id integer PRIMARY KEY autoincrement,"
+ "jiqiname text, jiqiweizhi text)");
//机器存储数据表
db.execSQL("CREATE TABLE if not exists jiqi(id integer PRIMAR