i’m trying to use this code:
String message = "this is david's house";
String sql = "INSERT into " + TABLE + "(message) VALUES ('" + message + "')";
db.execSQL(sql);
db.close();
in order to insert the string into the db, but get this exception:
01-27 14:52:01.083: E/Database(727): Failure 1 (near "id": syntax error) on 0x12a038 when preparing 'INSERT into calls_table (message) VALUES ('this is david's house')'.
How can i make the SQLite get the comma?
You have to escape the
'properly:Or, if sqlite supports it (I don’t know), parameterized queries are better.
And just to have mentioned it: the
'is not a comma, it’s an apostrophe (at least I think that’s the correct name, I often confuse the name for that one).