jeudi 24 septembre 2015

Android SQLite case insesitive selection from table by text pattern

help!

I have a table with 2 columns: 'name' and 'phonenumber'. I need to select only names by input text pattern and sort matches alphabetically. I do the following:

String myPattern="abc";
Cursor c = db.query("MY_TABLE_NAME", null, "name LIKE ?", 
         new String[] {"%"+myPattern+"%"}, 
         null, null, "name Collate NOCASE", null);
if (c.moveToFirst())
{
  do {
        ......
  } while (c.moveToNext());
}
c.close();

It works just fine when all names are in lower case. But if a name record is 'Abc', it won't be selected.

Please, help to modify my code to make the selection case insensitive!

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire