Java 编译时发生SQLite语法错误:插入到
我在执行异步任务时遇到此RuntimeException:Java 编译时发生SQLite语法错误:插入到,java,android,sqlite,android-sqlite,runtimeexception,Java,Android,Sqlite,Android Sqlite,Runtimeexception,我在执行异步任务时遇到此RuntimeException: Caused by: android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: INSERT INTO 'infrastructure' (lift,name,type,status,_id) VALUES ('2130837612','none','-','2130837600',0),('2130837612','none'
Caused by: android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: INSERT INTO 'infrastructure' (lift,name,type,status,_id) VALUES ('2130837612','none','-','2130837600',0),('2130837612','none','-','2130837600',1),('2130837612','none','-','2130837600',2),('2130837612','none','-','2130837600',3),('2130837612','none','-','2130837600',4),('2130837612','none','-','2130837600',5)
除_id之外的所有列都是“text”、_id是一个整数和主键
这就是它崩溃的地方:
Cursor curtsr = db.rawQuery("SELECT COUNT(*) FROM 'Infrastructure'", null);
if (curtsr != null) {
curtsr.moveToFirst(); // Always one row returned.
if (curtsr.getInt(0) == 0) { // Zero count means empty table.
String INSERT_INFRA_VALUES = "INSERT INTO 'Infrastructure' (lift,name,type,status,_id) VALUES ('2130837612','none','-','2130837600',0),('2130837612','none','-','2130837600',1),('2130837612','none','-','2130837600',2),('2130837612','none','-','2130837600',3),('2130837612','none','-','2130837600',4),('2130837612','none','-','2130837600',5)";
db.execSQL(INSERT_INFRA_VALUES);
}
curtsr.close();
}
我找不到它崩溃的原因
联机SQLite lint工具没有抛出任何错误。仅在SQLite 3.7.11中引入,您可能正在运行。不要对表名和列名使用单引号。我投票决定结束诸如简单的印刷错误之类的问题。@GordonLinoff从表名中删除引号并没有改变一件事。这解释了很多。我使用的是API级别15。3.7.11适用于API 16+