rawQuery(query, selectionArgs)

sree_iphonedev picture sree_iphonedev · May 15, 2012 · Viewed 174.6k times · Source

I want to use select query for retrieving data from table. I have found, rawQuery(query, selectionArgs) method of SQLiteDatabase class to retrieve data. But I don't know how the query and selectionArgs should be passed to rawQuery method?

Answer

Rawkode picture Rawkode · May 15, 2012
rawQuery("SELECT id, name FROM people WHERE name = ? AND id = ?", new String[] {"David", "2"});

You pass a string array with an equal number of elements as you have "?"