Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android real escape string in sqlite

Tags:

android

sqlite

How can i use php real_escape_string in android sqlite?

when i add the following to my table row's value "asd'" then i getting a crash because of "'" char. How can I escape illegal characters in android sqlite?

Thanks

edit: in android, not php

like image 684
lacas Avatar asked Aug 31 '11 07:08

lacas


1 Answers

I think an equivalent function is DatabaseUtils.sqlEscapeString(stringToEscape). (Javadoc: SQL_escape a string).

If you are using the SQLiteDatabase insert method taking a ContentValues as a parameter, these may be automatically escaped for you, but I'm not 100% (and I haven't been able to check).

like image 119
epochengine Avatar answered Oct 20 '22 04:10

epochengine