how to read value from string.xml in android?
In Activity:
this.getString(R.string.resource_name)
If not in activity but have access to context:
context.getString(R.string.resource_name)
application.getString(R.string.resource_name)
Try this
String mess = getResources().getString(R.string.mess_1);
UPDATE
String string = getString(R.string.hello);
You can use either getString(int)
or getText(int)
to retrieve a string. getText(int)
will retain any rich text styling applied to the string.
Reference: https://developer.android.com/guide/topics/resources/string-resource.html