Possible Duplicate:
How to escape special characters like ' in sqlite in android
I'm using a form to store some values in an Android's SQLite database. If any of the fields contains the character ' an error occurs so I tried to escape it, but the error is still there.
This is my code:
public boolean createCalendar(String id, String name, String descr) {
try{
String newDescr = descr.replace("'", "\\'");
db.execSQL("INSERT INTO Calendar (id, name, description) VALUES " +
"('"+id+"','"+name+"','"+newDescr+"');");
...
}
}
And this is the error:
sqlite returned: error code = 1, msg = near "siksjs": syntax error, db=/data/data/com.pfc.app/databases/SSDB
android.database.sqlite.SQLiteException: near "siksjs": syntax error: , while compiling: INSERT INTO Calendar (id, name, description) VALUES ('43779fcb-3d8c-650b-b529-50810506375e','kdldlls','ddk \' siksjs');
How am I supposed to store it?
Thanks!