以下是构建我的查询的代码,稍后在我的代码中由execSQL()
调用。
public static final String TABLE_NAME = "active";
public static final String COLUMN_NAME_ORDER = "order";
public static final String COLUMN_NAME_TITLE = "title";
public static final String COLUMN_NAME_CONTENTS = "contents";
//SQL Queries
public static final String TEXT_TYPE = " TEXT";
public static final String COMMA = ",";
public static final String SQL_CREATE_TABLE_ACTIVE =
"CREATE TABLE " + ActiveTasks.TABLE_NAME + " (" +
ActiveTasks._ID + " INTEGER PRIMARY KEY AUTOINCREMENT" + COMMA +
ActiveTasks.COLUMN_NAME_ORDER + TEXT_TYPE + COMMA +
ActiveTasks.COLUMN_NAME_TITLE + TEXT_TYPE + COMMA +
ActiveTasks.COLUMN_NAME_CONTENTS + TEXT_TYPE +
" );";
这是execSQL的声明:
@Override
public void onCreate(SQLiteDatabase db) {
Log.v(LOG_TAG, DataContract.ActiveTasks.SQL_CREATE_TABLE_ACTIVE);
db.execSQL(DataContract.ActiveTasks.SQL_CREATE_TABLE_ACTIVE);
}
当调用onCreate方法时,我在日志中得到以下内容。
925 16102-16119/xxxxxxxx V/ActiveDatabaseHelper﹕ CREATE TABLE active (_id INTEGER PRIMARY KEY AUTOINCREMENT,order TEXT,title TEXT,contents TEXT );
16102-16119/xxxxxxxx E/SQLiteLog﹕ (1) near "order": syntax error
我不相信我忽略了任何事情,如果这是真的,我可能做错了什么? 此外,我已确认问题位于Oncreate方法中。
提前谢谢, - 山姆。是的,我已经查看了多个SO问题和答案,描述了我遇到的同样问题。他们对我的情况没有帮助。