Here is the code that constructs my query that is called by execSQL() later in my code.
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 +
" );";
And here is the execSQL statment:
@Override
public void onCreate(SQLiteDatabase db) {
Log.v(LOG_TAG, DataContract.ActiveTasks.SQL_CREATE_TABLE_ACTIVE);
db.execSQL(DataContract.ActiveTasks.SQL_CREATE_TABLE_ACTIVE);
}
When the onCreate method is called, I get the following in my log.
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
I do not believe I have overlooked anything, and if that is true, what could I be doing wrong? Also, I have confirmed that the problem is located in the Oncreate method.
Thanks in advance, - Sam. And Yes, I have viewed multiple SO questions and answers describing the same problem I am having. They do not help my situation.
Order is Sql keyword. you should use it with in quotes. Refer Here for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With