public class NoteDatabase extends SQLiteOpenHelper {
public static final String TABLE_NAME="notes";
public static final String CONTENT="content";//内容
public static final String ID="_id";
public static final String TIME="time";
public static final String MODE="mode";//TAG
public NoteDatabase(Context context){
super(context,"notes",null,1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE "+ TABLE_NAME
+ "("
+ ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"//自然增长ID作为主键
+ CONTENT + " TEXT NOT NULL,"
+ TIME + " TEXT NOT NULL,"
+ MODE + " INTEGER DEFAULT 1)"
);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {//更新版本
// for (int i=oldVersion;i<newVersion;i++){
// switch (i){
// case 1:
// break;
// case 2:
// updateMode(db);
// default:
// break;
// }
// }
}
}
NoteDatabase
最新推荐文章于 2024-01-03 20:18:06 发布