I would like to know what are the user-preferred units between miles and meters. It seems that the "Locale" class doesn't allow that.
4 Answers
Although there isn't a way to get the preferred units using Locale, you can assume by default that if the Locale indicates the United States or Myanmar (locale.getISO3Country().equalsIgnoreCase("usa") || locale.getISO3Country().equalsIgnoreCase("mmr")
) the preferred units are imperial, otherwise the preferred units are metric. In any case where units may be shown in either imperial or metric form, the measurement system shown should be a user-settable preference.
There are certain idiosyncrasies involving units in some countries. (See also the accepted answer at the time of this writing.) For example, although the preferred everyday units in the United Kingdom are metric units, there are some exceptions, notably—
- miles and miles per hour, in ground transportation;
- miles per hour, in wind speeds;
- pints and gallons, for milk and beer (but not most other foods and beverages); and
- stone, or stone and pounds, for a person's weight.

- 32,158
- 14
- 82
- 96
-
1Doesn't England also use the Imperial system? – KevinDTimm Aug 11 '11 at 13:00
-
1@KevinDTimm: In some cases (such as in alcoholic drinks and the like), but definitely not to the same extent as the United States. Therefore, this is merely a _default_ assumption. – Peter O. Aug 11 '11 at 13:02
-
1IIRC, they measure distance (on the roads) as miles - see http://answers.yahoo.com/question/index?qid=20080614151814AAtg1zo – KevinDTimm Aug 11 '11 at 13:04
-
And in Canada and Australia ? Which units do they use ? Thanks guys ! – toto_tata Aug 12 '11 at 08:04
-
1If you use this solution, IMHO better code is: `mLocale.getISO3Country().equalsIgnoreCase(Locale.US.getISO3Country())` – Sean Barbeau Aug 11 '14 at 17:29
-
1Almost correct. As [per Wikipedia](https://en.wikipedia.org/wiki/Metrication#Chronology_and_status_of_conversion_by_country) only US **and Myanmar** haven't adopted the Metric system. Therefore just check for language code `xx_US` or `xx_MY` (the [latter is Myanmar](http://www.science.co.il/Language/Locale-codes.asp)) and only use the imperial system for those two. – adib Jun 13 '15 at 08:46
-
Liberia should also be on that list according to wikipedia, and Myanmar is converting to metric – Christophe Le Besnerais Nov 09 '22 at 17:17
I don't think there's necessarily a correct answer to the Metric/Imperial question for all locales.
For example, in the UK we generally use miles for large distances like a car journey, feet and inches for people's height but may use meters to describe the dimensions of a room.
We almost always use litres for measuring liquid volume except for beer and sometimes milk which can still be sold in pints.
Kilograms are usually preferred to pounds and ounces but most recipe books will list both since some people still have scales which use the latter.
I think you will have to do some research to find out which countries use which scale for what you're interested in measuring (and of course, give the user the option to select one or the other manually.)

- 1,380
- 10
- 15
-
Thanks for sharing. Do you think the "average car driver" in the UK or USA is able to convert km/h into miles immediately (aka while driving)? – Martin Pfeffer Sep 20 '15 at 09:22
Since some people outside the US may have set the language to English (US) it is eventually better to take the return value of getSimCountryIso()
instead of getISO3Country()
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String countryCode = tm.getSimCountryIso();
If the countryCode
is us
the SIM card is an american and therefore imperial units might be the better choice - in any other case the metric system is applied

- 13,532
- 8
- 45
- 55
-
5It's wrong. you are for proposing solution based on optional component, which is just half-baked hack – Marcin Orlowski Jun 06 '13 at 10:57
-
1down vote I think it is good to check if there is a SIM card first, and then if it fails use locale. I absolutely agree, my phone is set to US, though I am not from there and I use metric system... – Ivan Ičin Sep 29 '13 at 23:57
-
1But when I travel to another country and use their sim, I don't want their measurement units, I want mine – behelit Oct 10 '18 at 00:53
Build a
Locale : Country : Metric
You can use
Locale.getDefault()
to get an appropriate locale for the user of the device you're running onPerform a search on the built table
Result is yours!

- 171,228
- 44
- 289
- 238

- 2,019
- 3
- 18
- 39