tags:

views:

644

answers:

2

dear frineds,

i have written line

String Mess= R.string.mess_1 ;

to get string value but instead of returning string it is giving me id of type integer can any one guide me how can i get its string value that i have mentioned in string.xml file??

any help would be appriciated.

A: 

You can try this:

String mess = Resources.getText(R.string.mess_1);
Andi
not working.. giving error String mess=Resources.getText(R.string.mess_1).toString();Cannot make a static reference to the non-static method getText(int) from the type
UMMA
+4  A: 

Try this

String mess = getResources().getString(R.string.mess_1);

More info here

ccheneson
thanks dude.... ;)
UMMA
you can simplify that to `this.getString(R.string.some_id)` if you're already in a `Context` (Activity or Service).
Matthias