Since I targeted a newer SDK version of Android, I have been getting a warning on this line of code:
return getString(R.string.usertab1).toUpperCase()
When I hover over it, it says:
Implicitly using the default locale is a common source of bugs: Use
toUpperCase(Locale)instead.
Does anyone know how to remove this error? And why is it now a preferred way to use this method?
I get this is the answer, to use toUpperCase(Locale) but having trouble implementing it. Where does the Locale object come from?
You could explicitly use the default locale:
Basically, you don’t want to implicitly allow the device to use the default, because this can mean you simply ignored the fact that it could be an issue. For machine-readable content, you may want to specify a specific locale (such as
Locale.ENGLISH) to ensure you always get the reusability you want out of the data. For showing the user, explicitly specifying the default locale should be fine.For a more complete read: