Android ADT 21.0 warning: implicitly use standard locale

I updated ADT to 21, and a 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 am trying:

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

But the error still remains! How to fix it?

+58
android adt
Nov 18
source share
6 answers

You should use Locale.getDefault() , especially if you are not sure that your text will always be in English. In addition, pile errors like the ones you usually disappear run again or clear your project.

+107
Nov 18 '12 at 21:25
source share

You just need to clean the project

+31
Nov 20 '12 at 10:37
source share

Actually, use Locale.getDefault() when the goal is to provide text to the user. However, and this is the whole point of checking Lint, you should probably use Locale.US whenever the goal is to read / use the machine. Since it already implicitly uses Locale.getDefault() if you do not specify it, and this can cause difficulties in detecting errors if they have their own default locale. It looks like you also need to clean your project anyway, like everyone else.

+6
Mar 08 '13 at 19:12
source share

use Locale.getDefault () and clean up the project.

+3
Mar 04 '13 at 6:45
source share

This is probably a Lint bug. Just try to cut the whole line of code

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

save, then paste.

+1
May 8 '14 at 21:29
source share

Cleaning up the project did not help me, so I added the default locale to my code:

String.format(Locale.getDefault(), "firstname: %s, lastname: %s", firstName, lastName));

Depending on your project, you might take a look at Locale .

+1
Jul 19 '16 at 17:03
source share



All Articles