Android ADT 21.0 warning: Implicitly using the default locale

rocknow picture rocknow · Nov 18, 2012 · Viewed 33.7k times · Source

I've updated ADT to v. 21 and new warning appeared in this code:

if (e.getMessage().toLowerCase().contains("blabla"))

Implicitly using the default locale is a common source of bugs: Use toLowerCase(Locale) instead

So I try:

if (e.getMessage().toLowerCase(Locale.ENGLISH).contains("blabla"))

But error still remained! How fix this?

Answer

Gabriel Netto picture Gabriel Netto · Nov 18, 2012

You should use Locale.getDefault() especially if you cant be sure that your text will always be in english. Also lint errors like that one you are having usually disappear after you run lint again or clean your project.