Android SQLiteException:我瞎了吗?

Android SQLiteException: am I blind?

我的 logcat

中有以下异常
Caused by: android.database.sqlite.SQLiteException: near "from": syntax error (code 1): , while compiling: create table subsectionTable(id2 integer primary key autoincrement,line text not null,from text not null,to text not null);

我是瞎了眼才发现问题。

这是我创建的字符串:

private static final String SUBSECTION_CREATE_STATEMENT = "create table " + TABLE_SUBSECTIONS
            + "(" + COLUMN_ID2 + " integer primary key autoincrement,"
            + COLUMN_LINE + " text not null,"
            + COLUMN_FROM + " text not null,"
            + COLUMN_TO + " text not null);";

你能帮我找到错误的条目吗?

此致, 菲利克斯

from 是 SQLITE 中的关键字。您正在尝试将列 COLUMN_FROM 命名为 from。为该列使用不同的名称。应该没问题。

您不能使用 from 关键字作为您的字段名称。改个名字应该就可以了