Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7975817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:44:57+00:00 2026-06-04T08:44:57+00:00

The Android documentation here http://developer.android.com/guide/topics/resources/localization.html explains that you can get the current locale with

  • 0

The Android documentation here http://developer.android.com/guide/topics/resources/localization.html explains that you can get the current locale with this method:

context.getResources().getConfiguration().locale

It seems Java already provides this information in the form of this method:

java.util.Locale.getDefault()

So why did the Android developers introduce another way to get the locale? Would the above two lines of code ever produce different results when run side-by-side at the same time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:44:59+00:00Added an answer on June 4, 2026 at 8:44 am

    I agree it is confusing and while I am not attacking it nor am I defending it I can see it allowing you to do some things.

    Let’s start from the beginning.

    java.util.Locale.getDefault() is defined by the java runtime. It is the locale of the phone/device. It is what powers things like DateFormats (ISO Dateformat standard, US format standard, etc), NumberFormats (comma’s or decimals, groupings of 3 or 4, etc) and CurrenyFormats (Does it look like a $ or a CAD) when no locale is given. For these cases it’s probably best to specify the Locale to these types of objects anyways.

    context.getResources().getConfiguration().locale is the locale that is registered with the current resources pack in the given Context. It can include the locale value that all the resource content will respect for the current context/resources pair. The configuration can be sort of like the current state of the device that best filtered to the current resources. You don’t necessarily need to specify any content that changes based on locale, but it’s an option.

    Resources use a set of discriminators in the Configuration like orientation, screen width, locale, etc. So within your app you might allow overriding the current Resources() with another by just changing the locale app configuration to a different locale. Like for example, you were making a layout for an address. You might want certain fields to morph depending on what the country selected is. (Not saying this is correct behavior for such an app but it’s the simplest thing to think of right now). If you had to simply rely on Locale.getDefault(), it would make for some awkward resetting of system apps and state when you wanted to do something as I just described.

    You would essentially be required to modify the Locale for the entire device (this isn’t necessarily safe, nor is it something any old user would enjoy). Even if we disregard the security manager issues that would be duplicated by the host vm; on most devices there is a lot of state that is cached for the country kit. So there would be considerable lag and probably a lot of instability while switching this value over (If anyone could do it that is). The other alternative would to be always specify the locale for everything. You could see how annoying that would be. So it’s inside the Context’s Configuration.

    So while it’s awkward, it does provide an extra degree of freedom and protection, and convenience. Most of the time it will be Locale.getDefault() since your Application was started from a process that’s base context was initialized to Locale.getDefault(). In general I would shy away from using the Locale.getDefault() value too much. There aren’t too many times in consumer app development when it would be something that should be trusted.

    Again not based on fact since I am not a OS dev, just mostly based on analyzing the pros and cons of the system. I think the locale in the configuration is completely reasonable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The documentation ( http://developer.android.com/guide/topics/manifest/manifest-element.html#uid ) only states I can't use raw strings and the
I was reading this documentation page, http://developer.android.com/reference/android/util/Log.html . The section here caught my eye:
I'm having trouble with http://developer.android.com/resources/articles/painless-threading.html It's been touted as a great source of information
i was just going through the documentation given on developer.android.com and when i was
I am using sqlitegen(http://code.google.com/p/sqlitegen/) plugin in eclipse for android. The documentation for using it
The Android documentation says that best practices are to make two drawable directories -
I want to have a full documentation for android ndk. or a url that
Following is from Android Documentation You can acquire a lookup key from the contact
I've been scouring the interwebs (e.g. Android documentation, answers here, etc.) for the answer
The Android documentation says the following about IntentService: [IntentService] creates a work queue that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.