今天课比较多,但是还是要抽出时间写安卓,又有了一些小进展,将数据库的部分代码写了出来
可以参考一下
package com.example.clockappliction; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import androidx.annotation.Nullable; public class DB extends SQLiteOpenHelper { private static final int DATABASE_VERSION=4; private static final String DATABASE_NAME="crud.db"; public DB(Context context) { super(context,DATABASE_NAME,null,DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { String CREATE_TABLE_USER="CREATE TABLE " + Student.TABLE +"(" +Student.KEYWORD+" INTEGER PRIMARY KEY AUTOINCREMENT ," +Student.ID+" TEXT ," +Student.NAME+" TEXT ," +Student.GRADE+" TEXT ," +Student.PHONE+" TEXT)"; String CREATE_TABLE_CLOCK="CREATE TABLE " + Clock.TABLE +"(" +Clock.KEYWORD+" INTEGER PRIMARY KEY AUTOINCREMENT ," +Clock.DATE+" TEXT ," +Clock.WORD+" TEXT ," +Clock.SUMMARY+" TEXT ," +Clock.MAXDAY+" TEXT)"; } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS "+ Student.TABLE); db.execSQL("DROP TABLE IF EXISTS "+ Clock.TABLE); onCreate(db); } }
标签:Clock,TEXT,APP,db,Student,TABLE,打卡,Android,CREATE From: https://www.cnblogs.com/rsy-bxf150/p/17177089.html