Search code examples
javaandroidjvmlocale

Is Locale.setDefault() safe?


My app users can change app language from app's setting page so I developed it with Resources.updateConfiguration() and Context.createConfigurationContext() (For deprecating). However almost developer used with Locale.setDefault() but I don't know why. My app can support multi language without Locale.setDefault(). I read document, but it seems like too dangerous. Is changing JVM's locale safe for system settings or other app? What is changing JVM locale for? And I think it's enough that using Resource.updateConfiguration() and Context.createConfigurationContext() but why developers use Locale.setDefault() method?


Solution

  • I assume that "safe" means "does not affect other apps"

    As far as I know android starts a new JVM instance for every started apk/app. Hence Locale.setDefault() should not influence other android apks/apps. So it should be safe.

    I have done it here and saw no effects on other apps.