Search code examples
androidlocale

What is the difference between locale using Locale.getDefault() and context.getResources().getConfiguration().locale?


Is there any difference between String returned by:

Locale.getDefault().toString()

and

context.getResources().getConfiguration().locale.toString()

Asking because I suspect this is causing a bug in app, something which worked before using Locale.getDefault().toString() is not working anymore with context.getResources().getConfiguration().locale.toString(), on some US devices. But not sure if this is the reason.

Thanks!


Solution

  • Locale.getDefault().toString() and context.getResources().getConfiguration().locale.toString() should return the same value.

    The only major difference between the two is that the Locale.getDefault() can be directly overridden by Locale.setDefault(locale). (Which will also affect context.getResources().getConfiguration().locale.toString())