Skip to content Skip to sidebar Skip to footer

How To Avoid Different Letters Cases (á, É, Í, Ó, Ú) In Search Mode - Android

I'm building an app that should replace the default contacts phone book, and I want to add a search bar for search a contact's name. For now I have all the contacts in my own DB an

Solution 1:

You can use java.text.Normalizer to strip accents.

StringstrippedAccent= Normalizer.normalize(someText, Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "");

f you want to use it in a query, you should probably add a field into your DB containing the stripped-down version of the searchable text.

Solution 2:

This change worked that quite well for nubdial. It's reasonably fast, too.

Post a Comment for "How To Avoid Different Letters Cases (á, É, Í, Ó, Ú) In Search Mode - Android"