Search code examples
androidlocale

Is every android phone has en_US locale?


I wonder is every android phone has the en_US locale preinstalled? I have to pre-set the Locale in order to prevent comma separator issue.

Currently, I'm using the method below to force change, but I worried exceptions might happen on some devices.

            Locale locale = new Locale("en_US");
            Locale.setDefault(locale);
            Configuration config = new Configuration();
            config.locale = locale;
            getBaseContext().getResources().updateConfiguration(config,
                    getBaseContext().getResources().getDisplayMetrics());

Solution

  • They most likely have it.

    In case you would like to check regardless, you could do something like this:

    Locale locale = new Locale("en_US");
    List availableLocales = Arrays.asList(Locale.getAvailableLocales());
    
    if(!availableLocales.contains(locale)) {
        // en_US locale not available, do your stuff here accordingly
    }