任务:完成了后台数据库的类模块
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) { } }