I\'m working on an app that wants to display lengths either in centimeters (cm) or in inches(\"). Is there a way to select the right unit from the locale? In any event I\'m also
Building on the other nice solutions here, you can also implement this as a Kotlin extension function to the Locale object:
fun Locale.isMetric(): Boolean {
return when (country.toUpperCase(this)) {
"US", "LR", "MM" -> false
else -> true
}
}
This way, all you need to do is call:
val metric = Locale.getDefault().isMetric()