views:

8487

answers:

2

Hi, I use this query in my android database, but It return no data. Am I missing something?

SQLiteDatabase db = mDbHelper.getReadableDatabase();
    String select = "Select _id, title, title_raw from search Where(title_raw like " + "'%Smith%'" +
 ")";     
    Cursor cursor = db.query(TABLE_NAME, FROM, 
      select, null, null, null, null);
    startManagingCursor(cursor);
    return cursor;
+4  A: 

This will return you the required cursor

Cursor cursor = db.query(TABLE_NAME, new String[] {"_id", "title", "title_raw"}, 
                "title_raw like " + "'%Smith%'", null, null, null, null);
Prashast
Thanks! It's work!
Dennie
Do you just pass `null` if you want the `where` condition to be "everything"?
Matt Huggins
+4  A: 

Alternatively, db.rawQuery(sql, selectionArgs) exists.

Cursor c = db.rawQuery(select, null);
xiojason
It's also helpful! Thanks!
Dennie