3

In application supporting multiple languages using Locale.setDefault(newLocale); we are changing the language but there is no way to change language to device default language. What is the best way to find device default language in settings programatically.

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Vishal Pawar
  • 4,324
  • 4
  • 28
  • 54

3 Answers3

5

check this:

Resources.getSystem().getConfiguration().locale.getLanguage();

Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
2

In general, store user modifiable setting in a variable controlled by you, not Oracle. I.e. never call Locale.setDefault when user changes your application's locale, but rather change a variable under your control.

There are overrides for each locale-dependent method that take Locale parameter.

That's where you should pass locale variable under your control.

This way, you can always consult Locale.getDefault for system settings.

Alexander Pogrebnyak
  • 44,836
  • 10
  • 105
  • 121
  • thanks for your answer but its in context of android so Locale.setDefault is useful to me to set the new language in app – Vishal Pawar Jan 16 '16 at 13:56
0

Here's what you're looking for

Locale.getDefault().getLanguage();
John S.
  • 626
  • 1
  • 4
  • 16