我有一个创建表的 DatabaseHelper 类。第一个表(记录)工作正常,但第二个表在我尝试使用它时抛出异常(插入/选择...)。
这是我来自 DatabaseHelper 的代码:
public void onCreate(SQLiteDatabase db) {
String createTable="CREATE TABLE recordings" +
"(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
" name VARCHAR(255) NOT NULL," +
" datestart VARCHAR(255) NOT NULL" +
")";
String createTable2="CREATE TABLE recording_image" +
"(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
"imageurl VARCHAR(255) NOT NULL," +
"imagetime INTEGER NOT NULL," +
"prot_id INTEGER NOT NULL," +
"FOREIGN KEY(prot_id) REFERENCES recordings(_id) ON DELETE CASCADE" +
")";
db.execSQL(createTable);
db.execSQL(createTable2);
}
例外是:
没有这样的表:recording_image。
什么可能导致这个问题?