SQLite数据库的使用

时间:2024-10-12 07:01:06
class MyDataBaseHelper extends SQLiteOpenHelper { public static final String CREATE_USERS= "create table users (" + "id integer primary key autoincrement, " + "username text, " + "password text, " + "age integer)"; private Context mContext; public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){ super(context, name, factory, version); mContext = context; } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE_USERS); Toast.makeText(mContext, "数据库创建成功!", Toast.LENGTH_SHORT).show(); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){ } }