0

Hello Developers, i am working with android sqlite database here i have some confusion with database query with like statement ,below i am giving an example of how the query look like-

String query_al_hilites="select  HighlightedWord from tablexyz Where BookTitle=? and HighlightedWord LIKE ?";

        Cursor cur_get_all_highlites=db.rawQuery( query_al_hilites, new String[] {open_title,"'%"+search_word+"%'"});

but my problem is that here i am binding string searchword with' ' or "" but some times search word contain that ' and " so query breaks ,please seggest me any way to avoid these kind of query breaks.

Thanks

ravi saini
  • 63
  • 7

1 Answers1

0

Maybe this will help you:

Cursor c = myDB.query(MY_DATABASE_TABLE, "songname","songname like ?" , new String[]{"%"+MATCH_STRING+"%"}, null,"SongHit", null);
Avijit
  • 3,834
  • 4
  • 33
  • 45