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.string.today
:
String column = myCursor.getString(myCursor.getColumnIndex(MainDb.NAME));
int resId = getApplicationContext().getResources().getIdentifier(column, "strings", getApplicationContext().getPackageName());
String buttonText;
if (resId != 0)
{
buttonText = getApplicationContext().getString(resId);
} else
{
buttonText = "Resource is null!";
}
resId
is always 0. Variable column
have the right value, I've checked it with debugger. I've tried different variations in resId
:
- "string" instead of "strings" in defType.
- Different variation of getResources like Resources.getSystem()...
- Different variation of getPackageName()
What I'm doing wrong?