4

I have a Dashboard.java file where I use strings.xml parsed in R.java auto generated file.

When I try to do:

    public String BASE_URL = R.string.BASE_URL;

Naturally will tell Cannot convert from int to String.

But that's what will be chosen from string.xml for the translation.

Is there a way around this?

Thanks

2
  • to extract the string for string.xml in the runtime for locale translation Commented Jul 28, 2013 at 15:21
  • You might see this (stackoverflow.com/questions/10812121/…) Commented Jul 28, 2013 at 15:39

2 Answers 2

10

Use This

String BASE_URL = getResources().getString(R.string.BASE_URL); 

or you can copy from the code below:

getResources().getString(R.string.BASE_URL); 
Sign up to request clarification or add additional context in comments.

Comments

1
     Resources res = getResources();
     String url = res.getString(R.string.hello_world);
     EditText et=(EditText)findViewById(R.id.editText1);
     et.setText(url);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.