I think this is a new error since switching to Android Studio 3.0. I am receiving a lint syntax error:
expected, got \'ON\'
Using the signed integer alternative syntax worked.
private static void setForeignKeyConstraintsEnabled(@NonNull SQLiteDatabase db) {
if (!db.isReadOnly()) {
db.execSQL("PRAGMA foreign_keys=1;");
}
}
private static void setForeignKeyConstraintsDisabled(@NonNull SQLiteDatabase db) {
if (!db.isReadOnly()) {
db.execSQL("PRAGMA foreign_keys=0;");
}
}
Interestingly, using the alternative syntax of yes/no flagged an error on no but not yes. I agree with @CommonsWare that this seems to be a lint bug.