0

I am have trouble accessing a string I stored in strings.xml and don't know why.

res/values/strings.xml

    <?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="FileBrowser">FileBrowser</string>
    <string name="menu_settings">Settings</string>
    <string name="up_one_level">..</string>
    <string name="current_dir">.</string>
</resources>

Code

this.directoryEntries.add(getString(R.string.current_dir)); //current_dir is not being seen
3
  • 1
    What error do you get when you build your app? Commented Feb 1, 2013 at 0:49
  • 1
    Make sure that you have imported your R-class and not android.R Commented Feb 1, 2013 at 0:56
  • Ahh that was it. Thanks Simon Commented Feb 1, 2013 at 1:00

2 Answers 2

2

Check that you did not add the following import by mistake:

import android.R

It happened to me several times this week.
Delete this line and everything will work as expected.

Sign up to request clarification or add additional context in comments.

1 Comment

Worth noting that if you paste java code into your kotlin project and you confirm the conversion to kotlin, it might auto add this line to your imports.
1

Usually this means you have an error in one of your XML files so it can't rebuild your resources. Look under the problems tab in Eclipse and you'll probably see an XML issue, could be in any of your XML files, not necessarily in strings.xml.

1 Comment

Ahh yes that was a problem too so there were actually 2 issues. Thanks guy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.