5

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! :)

  • Does this answer your question? [How to access values from strings.xml](https://stackoverflow.com/questions/44871481/how-to-access-values-from-strings-xml) – m'hd semps Jun 30 '20 at 12:39

2 Answers2

0

You can use to evaluating the resources:

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

or try this for local resources.

mdroid
  • 474
  • 3
  • 15
0

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(...)

m'hd semps
  • 564
  • 4
  • 14
  • i know that, but i think it's not problem in code. code works fine, and if I didn't stop while debugging and tried evaluate expression, i would't ever know I can't evaluate local resources. – Stipendija Jun 30 '20 at 12:46
  • but i don't know why I can't evaluate local resources. is it connected with kotlin, maybe android studio...don't know :( – Stipendija Jun 30 '20 at 12:47