I have some code (Android 2.3.3).
Pattern p = Pattern.compile(R.string.regexDate + R.string.regexTime + R.string.regexLast); The Pattern.compile(String string) method Pattern.compile(String string) requires a parameter as strings, but from string.xml I get an int . Those. I get the identifiers from R.java , but I need strings right away ...
The resources themselves from string.xml
<string name="regexDate" >^[2][\\d]{3}[0-1]{1}[\\d]{1}[0-3]{1}[\\d][_]</string> <string name="regexTime">[0-2][\\d]([0-5][\\d]){2}[_]</string> <string name="regexLast">[0]{3}[b][\\.][d][b]$</string> We read the documentation ...
One option to cast as a string:
String s = getString(R.string.regexDate); The second option:
Resources res = getResources(); res.getString(R.string.regexDate) I can not use these options, because getString(...), getResources() methods Eclipse does not see.
How can I take a string from string.xml right away, not its id ? If possible with an example.