个人冲刺(四阶段)——体温上报app(一阶段)

任务:完成了后台数据库的类模块

MyDBHelper.java

package com.example.helloworld;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

import androidx.annotation.Nullable;

public class MyDBHelper extends SQLiteOpenHelper {
    private Context context;
    public MyDBHelper(Context context,String name,int version) {
        super(context, name, null, version);
        this.context=context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql="create table personwendu(id integer primary key autoincrement, address varchar, name varchar, wendu varchar, dateandtime varchar)";
        db.execSQL(sql);
        Toast.makeText(context,"数据加入成",Toast.LENGTH_LONG).show();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}

 

posted @ 2021-02-02 08:23  CherriesOvO  阅读(43)  评论(0编辑  收藏  举报