Reputation: 317
I'm trying to acces my strings.xml from within the java code, but for some reason I can only acces some default android strings. This is what I do:
private static Context context;
context = getApplicationContext();
context.getString(R.string.somthing);
The R.string contains some strings but not what I have in strings.xml.
Upvotes: 0
Views: 224
Reputation: 33238
I think you imported android.R
so just remove it and import your R.class
like as
import your.package.name.R;
here your.package.name
is your package name which you write in your Manifest.xml
file.
Upvotes: 1
Reputation: 6892
Use this code instead
Resources resources = context.getResources();
resources.getString(R.string.something)
Upvotes: 0