I want list of escape character
for sqlite
in android
to add backslash before those.
Asked
Active
Viewed 2,214 times
3

Amir.KH
- 328
- 2
- 5
- 14
-
1possible duplicate of [How to escape special characters like ' in sqlite in android](http://stackoverflow.com/questions/12615113/how-to-escape-special-characters-like-in-sqlite-in-android) – Chris Stillwell Apr 29 '15 at 19:08
-
@ChrisS : sorry but I want list of escape character not how to – Amir.KH Apr 29 '15 at 19:09
-
I want list also for character like `-` `,` `'` Possible that prepare statement is the only way to manage it? – János Oct 02 '16 at 16:40
1 Answers
2
SQL does not use backslashes for escaping.
When string literals are written directly in the SQL command, they are delimited with single quotes; any single quote inside the string must be doubled.:
cursor = db.rawQuery("SELECT * FROM MyTable WHERE Text = 'with '' quote'",
null);
Table/column names can be delimited with double quotes; any double quote in the table/column name must be doubled.
If you use parameters (which is stronly recommended), you do not need to escape anything:
cursor = db.rawQuery("SELECT * FROM MyTable WHERE Text = ?",
new String[]{ "with ' quote" });

CL.
- 173,858
- 17
- 217
- 259