Nitish
Nitish

Reputation: 3155

Checking whether an android phone has a particular locale

How can I programmatically check whether a phone has a particular locale?

Upvotes: 4

Views: 305

Answers (1)

Cat
Cat

Reputation: 67502

You can fetch an array of Locales by using getAvailableLocales(), then iterate through it to see if it's available.

boolean hasLocale = false;
String myLocale = "en";
Locale[] locales = Locale.getAvailableLocales();
for (Locale locale : locales) {
    if (locale.getLanguage().equals(myLocale)) {
        hasLocale = true;
    }
}
// Value of `hasLocale` is what you want here!

Upvotes: 3

Related Questions