0

I have words in database that contains Camp and Càmp. Now when I enter the word Camp, it should fetch and display both the words. So how to write the query to match the accented letters a and à to read the words from database.

Below is the query after passing the search text.

public List<TableOfContents> searchForText(@Nullable String rootHash,
                                                        @Nullable String substring) {
    List<TableOfContentsNode> returnValue = null;
    String likeQuery = null;
    if (StringUtils.isNotEmpty(substring) && StringUtils.isNotEmpty(rootHash)) {

        likeQuery = "%" + substring + "%";
        Cursor cursor = mDatabase.query(Tables.TOC_NODES, null,
                                        Columns.NODE_HASH + " = ? AND (" +
                                        Columns.TEXT + " LIKE ? OR " +
                                        Columns.TITLE_BREAK + " = 1)",
                                        new String[] { rootHash, likeQuery }, null, null,
                                        Columns.SORT_ORDER + "ASC");

        returnValue = getFromCursor(cursor);
        cursor.close();
    }

Do I need to add anything in query to match both accented and normal character words? I read COLLATE NOACCENTS but i don't know where to use in above query.

Kindly help me.

Star
  • 735
  • 3
  • 13
  • 34
  • Possible duplicate of [SQLite accent-insensitive search](https://stackoverflow.com/questions/14009261/sqlite-accent-insensitive-search) – m0skit0 Oct 26 '18 at 12:51
  • No. It's not duplicate. @m0skit0 when I give like that, it displays unwanted not searched things too. (For eg: If I type Co, it displays Co but at the same time, it's displaying other related things too ) – Star Oct 26 '18 at 13:03

0 Answers0