| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package com.baoshi.swms.sqlite;
- import android.content.Context;
- import android.database.sqlite.SQLiteDatabase;
- import android.database.sqlite.SQLiteOpenHelper;
- import androidx.annotation.Nullable;
- /**
- * 任务表
- *
- * @author Zhendong Zhou
- * @date 2021/12/24 16:21
- */
- public class TaskTable extends SQLiteOpenHelper{
- public static final String TABLE_NAME = "task";
- private final String SQL;
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(SQL);
- }
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
- }
- private volatile static TaskTable uniqueInstance;
- public static TaskTable getInstance(Context context) {
- if (uniqueInstance == null) {
- synchronized (TaskTable.class) {
- if (uniqueInstance == null) {
- uniqueInstance = new TaskTable(context);
- }
- }
- }
- return uniqueInstance;
- }
- //重写SQLiteOpenHelper的有参构造方法
- public TaskTable(@Nullable Context context) {
- //第一个参数为Context对象,第二个参数为数据库名称,第三个设置为null,第四个为sql版本号
- super(context, "swms.db", null, 1);
- SQL="create table "+
- TABLE_NAME+"("+
- "id INTEGER PRIMARY KEY,"+
- "detailId integer,"+
- "location varchar(50),"+
- "way varchar(50),"+
- "barcode varchar(50),"+
- "barcodeAs varchar(50),"+
- "anticipatedQuantity int,"+
- "realQuantity int null,"+
- //这里日期用text格式存储
- "pickingTime text null"
- +")";
- }
- }
|