My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ?
            Asked
            
        
        
            Active
            
        
            Viewed 2.3k times
        
    35
            
            
        - 
                    using Locale you could set and app language – g7pro Mar 29 '17 at 11:34
 
4 Answers
69
            Get system language
Resources.getSystem().getConfiguration().locale.getLanguage();
Get app language
String currentLang = Locale.getDefault().getLanguage();
        VelocityPulse
        
- 613
 - 7
 - 13
 
        Elsunhoty
        
- 1,609
 - 14
 - 27
 
- 
                    7What do you mean by "get app language"? In case the system is set to a language not supported by the app, both will return the system language, even though the app displays in a different language. – arekolek Feb 12 '19 at 21:58
 - 
                    2Resources.getSystem().getConfiguration().locale.getLanguage() is deprecated – Agna JirKon Rx Sep 03 '19 at 12:53
 - 
                    1
 
7
            
            
        To Get System Language Use this:
String DeviceLang =Resources.getSystem().getConfiguration().locale.getLanguage();
And For the Application Language Use this:
String AppLang = Resources.getConfiguration().locale.getLanguage();
        Kaushik Khambhadiya
        
- 341
 - 4
 - 8
 
7
            
            
        Kotlin - Android X:
val currentSysLocale = Resources.getSystem().getConfiguration().locales[0]
val currentAppLocale = Locale.getDefault().getLanguage()
Log.d("sys locale","$currentSysLocale")
Log.d("app locale","$currentAppLocale")
        Alessandro Ornano
        
- 34,887
 - 11
 - 106
 - 133