chandan chandan - 1 month ago 5
Android Question

E/SQLiteLog: (1) near "From": syntax error

String CREATE_TABLE_MSG="CREATE TABLE "+TABLE_NAME_MSG+"("+FROM+" TEXT PRIMARY KEY,"+STATUS+" TEXT,"+MESSAGE+" TEXT,"+PIC+" TEXT,"+TYPE+" TEXT,"+TIME+" TEXT CURRENT_TIMESTAMP,"+SENDID+" TEXT AUTOINCREMENT"+")";
db.execSQL(CREATE_TABLE_MSG);

Answer

Refer to SQLite keywords

FROM is one of them. Case insensitive.

If you want to use a keyword as a name, you need to quote it

So, you need to quote the from column

CREATE TABLE messages (`FROM` TEXT PRIMARY KEY

Or, just rename the column so it isn't a keyword like _from

Comments