Can't Get String Resource From R.string.*
I have a SQlite table with two columns _id and name. For internationalization purpose I store the name like R.string.today Now I want to get string resource associated with R.strin
Solution 1:
I think it should be string
instead of strings
:
int resId = getApplicationContext().getResources()
.getIdentifier(column, "string", getApplicationContext().getPackageName());
Check as well whether the value of column
dsignates an identifier in your strings.xml
.
This is a nice example.
p.s.: instead of R.string.today
just store today
or extract store
from R.string.today
.
Resourcesr= getResources();
r.getIdentifier("today", "string", getPackageName()));
r.getIdentifier("R.string.today", "string", getPackageName())); // doesn't work
r.getIdentifier("R.string.today".replaceAll(".*\\.", ""), "string", getPackageName()));
Only first and third work.
Solution 2:
Try this
String str = context.getString(R.string.resId);
Post a Comment for "Can't Get String Resource From R.string.*"