Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot convert from int to String from R.java

Tags:

java

android

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

like image 735
Karl TinKode Avatar asked Dec 20 '22 02:12

Karl TinKode


1 Answers

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); 
like image 171
KOTIOS Avatar answered Jan 09 '23 16:01

KOTIOS