Gerardo Mendez Dot Gerardo Mendez Dot - 8 months ago 90
Android Question

Search for parts of a string in a content provider

Hello I'm implementing a searchview and inside onQueryTextChange everytime the user press a letter I want to search that in my DB. The onQueryTextChange is implemented and working I need help with the search, for example:

String selection = AplicationContract.ArtistEntry.COLUMN_NAME + " LIKE ?";
String[] selectionArgs = { "MAX" };

return new CursorLoader(getContext(),

That returns me a cursor if I have a name "MAX" in my db. But if the names in my db are "MAX","MASON","MEGAN","SEAN" so when I hit the letter M I want to search in my content provider for anyname with the letter M, the result would be "MAX","MASON","MEGAN"

Thank you


When using like statement, you should code like this demo:

select * from tb where c like "%M%"

just learn how to use it on this site:

In this case, you should correct the params:

String[] selectionArgs = { "M"+"%" };