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 7402547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:46:13+00:00 2026-05-29T04:46:13+00:00

In my application I would like create a settings where user can be able

  • 0

In my application I would like create a settings where user can be able to change the language according to his choice. For this i have created respective values folder and string files for each language. Also my code snippet is as follows:

public class MultiLanguage extends Activity implements OnClickListener {

    private Button germany, english, french;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.language);

        english = (Button) findViewById(R.id.english);
        english.setOnClickListener(this);

        germany = (Button) findViewById(R.id.germany);
        germany.setOnClickListener(this);

        french = (Button) findViewById(R.id.french);
        french.setOnClickListener(this);

    }

    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.english:
            setLocale("en");
            break;

        case R.id.germany:
            setLocale("de");
            break;

        case R.id.french:
            setLocale("fr");
            break;
        }
    }
    public void setLocale(String localStr) {

        Locale localeLang = new Locale(localStr);
        Locale.setDefault(localeLang);
        Configuration config = new Configuration();
        config.locale = localeLang;
        getBaseContext().getResources().updateConfiguration(config,
                getBaseContext().getResources().getDisplayMetrics());
        finish();
        Intent refreshActivity = new Intent(this, Home.class);
        refreshActivity.setAction(Intent.ACTION_CONFIGURATION_CHANGED);
        startActivity(refreshActivity);
    }

}

BUt each time I am coming out from the application and launching the app again the language selected became english. I am not getting the root of this problem.

In manifest file I have also mentioned the following line:

android:configChanges="locale"

Can any body correct the mistake I have made here.

  • 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-05-29T04:46:14+00:00Added an answer on May 29, 2026 at 4:46 am

    Aren’t you trying to reinvent the wheel?

    Why not using the default locale selected by the user on his phone? This is the preferred way in the Android ecosystem.

    The only thing you have to do is provide multiple versions (one per desired locale) of your resource files (e.g. values/strings.xml). If the user’s locale is not found in your application’s resources, it will default to the values/strings.xml. Else it will use values-[locale]/strings.xml

    More details: http://developer.android.com/guide/topics/resources/localization.html

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

Sidebar

Related Questions

I would like to create a photo/video capture application. I have created a CaptureView
I would like to create extend a Java Swing application to have a look
I'd like to create an application that would run on Google's appengine. However, this
I'm trying to create a .NET touchscreen application. I would like to be able
I would like to create an application wide keyboard shortcut for a Java Swing
I would like to create an application that runs on XBox 360 (downloaded using
I would like to create a Delphi application for Windows XP which allows dropping
I would like to create an application that downloads a PDF document from the
I would like to create a UIBarButtonItem on my iPhone application which has two
For a web application, I would like to create a simple but effective licensing

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.