开发者

How to escape special characters in sqlite in android?

I ma trying to insert some data开发者_如何学C into the database. The data contains single quotes. I tried to escape them with back slash like "Scr\'anton" while inserting the data:

INSERT INTO employee VALUES(4,'Jim','Halpert','Assistant Regional Manager','Manage',2,'Scr\'anton','570-222-2121','570-999-1212','jim@dundermifflin.com','halpert.jpg')

I tired to use DatabaseUtils.sqlEscapeString() with no effect at all. What is the best way to escape characters?


use double single quotes 'Scr''anton'


Take a look at StringEscapeUtils (details here), found in the Lang component of Apache Commons. You can easily download this and add it to your project.


You can use the method update http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜