2016-07-23 85 views
-4

我有我的logcatAndroid SQLiteException:我瞎了嗎?

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);"; 

你能幫我找到輸入錯誤?

最好的問候, 菲利克斯

回答

3

from是SQLite中的關鍵詞。您正試圖將您的列COLUMN_FROM命名爲from。爲該列使用不同的名稱。應該沒事。

+1

非常感謝你 – Cyberlander

1

您不能使用from關鍵字作爲您的字段名稱。重命名它,它應該沒問題。

+0

非常感謝你 – Cyberlander