Get the current language in the device

How can we choose the current language in Android devices?

#1 building

join Johan Pelgrim's answer


Is equivalent because the android.text.format.DateFormat class can be used interchangeably, for example

private static String zeroPad(int inValue, int inMinDigits) {
    return String.format(Locale.getDefault(), "%0" + inMinDigits + "d", inValue);


public static boolean is24HourFormat(Context context) {
    String value = Settings.System.getString(context.getContentResolver(),

    if (value == null) {
        Locale locale = context.getResources().getConfiguration().locale;

    // ... snip the rest ...

#2 building

as Locale reference The best way to get a language is:


This method is based on ISO 639-1 Returns a string with a language ID

#3 building

You can use this code to find the keyboard current

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
String locale = ims.getLocale();

#4 building

You can use it

boolean isLang = Locale.getDefault().getLanguage().equals("xx");

When "xx" is any language code, such as "en", "fr", "sp", "ar"..., etc

#5 building

I checked the Locale method on Android 4.1.2 device, and the result is as follows:

Locale.getDefault().getLanguage()       ---> en      
Locale.getDefault().getISO3Language()   ---> eng 
Locale.getDefault().getCountry()        ---> US 
Locale.getDefault().getISO3Country()    ---> USA 
Locale.getDefault().getDisplayCountry() ---> United States 
Locale.getDefault().getDisplayName()    ---> English (United States) 
Locale.getDefault().toString()          ---> en_US
Locale.getDefault().getDisplayLanguage()---> English

Tags: Android REST

Posted on Mon, 06 Jan 2020 12:48:44 -0800 by jfourman