The beginning of the request symbol in the constant android of the room

I tried the following query, but it does not give any result.

SELECT * FROM details WHERE name LIKE: name

I used AutoCompleteTextview to search. Is there a search query with a substring?

+4
source share
2 answers

As Moin Khan suggested, adding a wildcard to the string before sending it to Room helped me.

query = "%"+query+"%";
+4
source

Example:

@Query("SELECT * FROM user WHERE first_name LIKE :firstName ")
User findByName(String firstName);

I think u should use a different name for "name" .

-1
source

Source: https://habr.com/ru/post/1678307/


All Articles