Android - while debugging, can't evaluate getString() from resources

Viewed 561

so, I'm trying to debug my app, and i'm evaluating expression with following code line:

resources.getString(R.string.my_string);

I should get my string from strings.xml, but I get an error:

Method threw 'android.content.res.Resources$NotFoundException' exception.

Someone know why can't I approach resources while evaluating?

here you can see what I'm talking about

Thx to all! :)

2 Answers

You can use to evaluating the resources:

Resources.getSystem().getString(android.R.string.my_string);

or try this for local resources.

if you are in an activity val string: String = getString(R.string.your_string_id) if some where else pass the context to that method then myContext.getString(...)

Related