当在SQLiteOpenHelper的实现类的onCreate中创建表格时,会遇到下列问题
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table" + CrimeTable.Name + "(" +
"_id integer primary key autoincrement," +
CrimeTable.Cols.UUID + "," +
CrimeTable.Cols.TITLE + "," +
CrimeTable.Cols.DATE + "," +
CrimeTable.Cols.SOLVED +
")"
);
}
控制台打印的错误如下:
Caused by: android.database.sqlite.SQLiteException: near "tablecrimes": syntax error (code 1): , while compiling: create tablecrimes(_id integer primary key autoincrement,uuid,title,date,solved)
错误原因是:The missing space is what caused the issue as you can see in your first line of error report:
所以最重要的一点是:So yes the space between TABLE and TABLE_NAME is important !!!(在TABLE和TABLE_NAME中间的空格一定不要忘记)
版权声明:本文为Fighting_Boss原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。