Skip to content Skip to sidebar Skip to footer

Sql Query In Android - Search For Whole Or Part Of A String

I'm not experienced with SQL queries too much so I'm having some trouble in finding the solution to my problem. I have a list of Bookmarks, for example: Facebook, Developers Consol

Solution 1:

You can try this:

Stringwhere = Browser.BookmarkColumns.TITLE + " LIKE '%" + x +"%' OR "
            + Browser.BookmarkColumns.URL + " LIKE '%" + x +"%'";
            where = "(" + where + ") AND " + Browser.BookmarkColumns.BOOKMARK + " == 1";

where x is the text that user has inserted, i.e. face.

Hope this helps!

Solution 2:

You can use the SQL-keyword LIKE for this. Encapsulate it with the wildward (%) and you're way to go.

sqlite>select*from testtable where name like'%face%';
facebook|42

Post a Comment for "Sql Query In Android - Search For Whole Or Part Of A String"