mardi 1 mars 2016

android studio app case insensitive search from sqlite

I am working on a android application with sqlite database that store lots of standard english texts that have uppercase and lowercase words and it shows on the app, we have a search that right now is case sensitive and scroll between them with cursor

How I can return search string case insensitive from sqlite

this is my code on database

public List<String> getSearchedParagraph(String p) {
    String sectionId = "";
    List<String> result = new ArrayList<String>();
    String query = "SELECT Distinct(sectionId)  FROM paragraph where txt Like '%"
            +p+ "%'";
    Cursor cursor = db.rawQuery(query, null);
    if (cursor != null && cursor.getCount() > 0) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {

            result.add(cursor.getString(0));
            cursor.moveToNext();

        }
    }
    return result;
}

i tested String query = "SELECT Distinct(sectionId) FROM paragraph where txt Like '%" +p+ "%' COLLATE NOCASE"; but still no change

thanks

Aucun commentaire:

Enregistrer un commentaire