Android autocomplete with SQLite LIKE works partially Android autocomplete with SQLite LIKE works partially sqlite sqlite

Android autocomplete with SQLite LIKE works partially


If it's urgent, here a quick and dirty solution.

2.600 strings (1.300 cyrillic + 1.300 latin) are really few values to handle in memory: you can simply load all values from the SQLite with

select name, latin_name from restaurants

and then you can loop the result set in Java while searching for the matching string with a String.contains method. Just remember that contains method is case sensitive, so you should use something like this:

string1.toLowerCase().contains(string2.toLowerCase())


sqlite documentation link

The LIKE operator does a pattern matching comparison. The operand to the right of the LIKEoperator contains the pattern and the left hand operand contains the string to match against the pattern. A percent symbol ("%") in the LIKE pattern matches anysequence of zero or more characters in the string. An underscore ("_") in the LIKE pattern matches any single character in the string. Any other character matches itself or its lower/upper case equivalent (i.e. case-insensitive matching). (A bug: SQLite only understands upper/lower case for ASCII characters by default. The LIKE operator is case sensitive by default for unicode characters that arebeyond the ASCII range. For example, the expression 'a' LIKE 'A' is TRUE but 'æ' LIKE 'Æ'   is FALSE.)