I am trying to create a table but keep getting the same error over and over and I have been googling for the answer without any success.
The query that is run in onCreate() is:
CREATE TABLE Posts
(
PostID TEXT PRIMARY KEY,
CourseID TEXT,
FOREIGN KEY (CourseID) REFERENCES Courses (CourseID) ON DELETE CASCADE,
PostStartDate INTEGER NOT NULL,
PostEndDate INTEGER NOT NULL,
TeacherID TEXT,
FOREIGN KEY (TeacherID) REFERENCES Teachers (TeacherID) ON DELETE CASCADE,
PostDescription TEXT,
PostHidden INTEGER DEFAULT(0)
)
The error I get is:
08-04 14:24:24.018: I/com.re.placed.DBHandler(10656): android.database.sqlite.SQLiteException: near "PostStartDate": syntax error (code 1): , while compiling: CREATE TABLE Posts (... (removed the rest of the query)
I suspect that the error might have something to do with either the foreign key or the on delete cascade. The two refenced columns are created as:
CourseID TEXT PRIMARY KEY and TeacherID TEXT PRIMARY KEY
And to make sure that foreign keys are used i have written the onOpen method as:
@Override
public void onOpen(SQLiteDatabase db) {
db.execSQL("PRAGMA foreign_keys = ON;");
super.onOpen(db);
}
Any help or suggestions are appreciated.