Escape special characters in sqlite
I am trying to update a SQLite table in my Android application. Predicate for this update is built around a column which stores different resource URLs.
These URLs might contain special characters such as /~?=; (and even &).
My query looks like:
update TableName where columnVal = '/some/fake/~/id?u=0&am开发者_运维问答p;amp;rl=url';
The update query doesnt work; it does not identify the column satifying the condition.
How can I escape these characters?
Please advise.
You should be using the method update
instead of generating the SQL yourself. The built-in methods will do all the needed escaping for you.
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
Answered here: Android quotes within an sql query string
精彩评论