How can we get the current language selected in the Android device?
You can use Locale. getDefault(). getLanguage(); to get the usual language code (e.g. "de", "en").
Go to app > res > values > right-click > New > Value Resource File and name it as strings. Now, we have to select the qualifier as a locale from the available list and select the language as Gujarati from the drop-down list.
A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user.
I've checked the Locale methods on my Android 4.1.2 device, and the results:
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 Locale.getDefault().toLanguageTag() ---> en-US
If you want to get the selected language of your device, this might help you:
Locale.getDefault().getDisplayLanguage();
You can use Locale.getDefault().getLanguage();
to get the usual language code (e.g. "de", "en")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With