How to Get the current language in Android device?

AndroidApps/ApplicationsMobile Development

While doing internalization in android application, we should know what is the current language in android device. This example demonstrate about how to Get the current language in Android device.

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.

Step 2 − Add the following code to res/layout/activity_main.xml.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
      android:layout_height="wrap_content" />

In the above code we have taken Button. When user click on button, it will take device country name and language and append to text view.

Step 3 − Add the following code to src/

package com.example.andy.myapplication;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Locale;

public class MainActivity extends AppCompatActivity {
   TextView language;
   protected void onCreate(Bundle savedInstanceState) {
      language = findViewById(;
      Button button = findViewById(;
      button.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
            String languagename = Locale.getDefault().getDisplayLanguage();
            String country = Locale.getDefault().getCountry();
            language.setText("Language " + languagename + " Country name " + country);

In the above code, we have used Locale class to get Display language and country as shown below -

String languagename = Locale.getDefault().getDisplayLanguage();
String country = Locale.getDefault().getCountry();

Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Runicon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −

In the above result it shows initial screen when user click on button it will show country name and language as shown below -

Click here to download the project code

Published on 09-Apr-2019 12:13:57