android – How to find out the language of the phone's localization?


Which function to check the localization of the phone (the language in which the OS is). So that later, depending on the localization of the phone, a certain class is used for further actions.


  public static Locale getCurrentLocale(Context context){
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
          return context.getResources().getConfiguration().getLocales().get(0);
      } else{
          //noinspection deprecation
          return context.getResources().getConfiguration().locale;
Scroll to Top