Android Studio flagging error in SQLite pragma command, expected, got 'ON'

前端 未结 1 2001
没有蜡笔的小新
没有蜡笔的小新 2021-02-20 13:10

I think this is a new error since switching to Android Studio 3.0. I am receiving a lint syntax error:

expected, got \'ON\'

相关标签:
1条回答
  • 2021-02-20 13:57

    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.

    0 讨论(0)
提交回复
热议问题