嘿伙计们我一直在寻找关于如何在同一个项目中创建2个表的话题? 请你们给我一些例子或一些链接供我查找:)
private static final String DATABASE_NAME = "CAS_DB";
public static final String tbPerson = "PersonInfo";
public static final String tbColor = "ColorInfo";
我想要的是在一个数据库中创建2个表但我找不到任何示例
提前致谢
答案 0 :(得分:6)
private static final String PERSON_TABLE_CREATE =
"CREATE TABLE " + tbPerson +
" (" +
PERSON_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
PERSON_NAME + " TEXT);";
private static final String COLOR_TABLE_CREATE =
"CREATE TABLE " + tbColor +
" (" +
COLOR_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLOR_NAME + " TEXT);";
在数据库助手的onCreate方法中:
public void onCreate(SQLiteDatabase db) {
mDatabase = db;
mDatabase.execSQL(PERSON_TABLE_CREATE);
mDatabase.execSQL(COLOR_TABLE_CREATE);
}