_id2 つの列とを持つ SQlite テーブルがありnameます。国際化の目的で、次のような名前を保存しR.string.today
ます。次に、に関連付けられた文字列リソースを取得したい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は常に 0 です。変数columnには正しい値があり、デバッガーで確認しました。でさまざまなバリエーションを試しましたresId:
- defType の「strings」ではなく「string」。
- Resources.getSystem() のような getResources のさまざまなバリエーション...
- getPackageName() のさまざまなバリエーション
私が間違っていることは何ですか?