Wednesday 15 July 2015

sqlite - Android and SQLlite: escape quote and get it back -



sqlite - Android and SQLlite: escape quote and get it back -

i have save info within of sqllite. text info can contain quote ('). there way escape char on insert, , when getting info database?

in particular, name references file. file can named "hel'lo.file". before escaping database, should "hel''lo.file". when need 1 time again "hel'lo.file" string within db matches file name.

i'm using content provider , sqliteopenhelper.

inside content provider, insert i'm doing this:

_id = db.insert(texteditorcontract.noteentry.table_name, null, values);

my insert within activity:

contentvalues values = new contentvalues(); ... values.put(noteentry.column_title, getfiletitle()); uri recorduri = contentresolver.insert(noteentry.content_uri, values);

use sqliteopenhelper - can utilize prepared statements. see question: android sqlite example

edit

string file = "/storage/emulated/0/note/hello 'world.txt" string sql = "select _id recents percorso=? order _id asc"; string[] info = {file}; cursor cursor = database.rawquery(sql, data);

android sqlite escaping

No comments:

Post a Comment