0
private static final String MINDMAPS_TABLE_CREATE =
"create table mindmaps (_id integer primary key autoincrement, "
+ "title text not null);";
private static final String BUBBLES_TABLE_CREATE =
"create table bubbles (_id integer primary key autoincrement, "
+ "title text not null), " +
"_bmid integer, " +
" FOREIGN KEY (_bmid) REFERENCES mindmaps (_id))";
private static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(MINDMAPS_TABLE_CREATE);
db.execSQL(BUBBLES_TABLE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS bubbles");
db.execSQL("DROP TABLE IF EXISTS mindmaps");
onCreate(db);
}
}
表我得到异常如下:无法创建与外键
Caused by: android.database.sqlite.SQLiteException: near ",": syntax error (code 1): , while compiling: create table bubbles (_id integer primary key autoincrement, title text not null), _bmid integer, FOREIGN KEY (_bmid) REFERENCES mindmaps (_id))
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
什么是错的声明?