Reputation: 1889
I mean the name, not it's values, for example this:
<resources>
<string name="magical_value_1">Lapin</string><br>
<string name="magical_value_2">Poulet</string><br>
<string name="magical_value_3">Saucisse</string><br>
</resources>
if i use String value1 = getResources().getString(R.string.magical_value_1);
the result it's going to be Lapin, but I need a way to get "magical_value_1"
(not Lapin) in a variable. I need to do this because of languages, I have a lot languages in my app,and their values changes, but the name(magical_value_1) it's the only thing that remains(regardless the language). thanks
Upvotes: 0
Views: 65
Reputation: 1423
If you are trying make your apps to support multiple language. Here's some simple sample.
Let's say you are trying to make your apps to support france and english. You needs to create res/values/strings.xml for english (Be precisely, other language then france) and res/values-fr/strings.xml for france.
Inside res/values-fr/string.xml
<resources>
<string name="magical_value_1">Lapin</string><br>
<string name="magical_value_2">Poulet</string><br>
<string name="magical_value_3">Saucisse</string><br>
</resources>
And inside res/values/string.xml
<resources>
<string name="magical_value_1">Rabbit</string><br>
<string name="magical_value_2">Chicken</string><br>
<string name="magical_value_3">Sausage</string><br>
</resources>
To test it by changing your device language on settings.
Upvotes: 1
Reputation: 16526
You should consider take a look to i18n android developer documentation.
Upvotes: 1
Reputation: 11028
See this answer.
tl;dnr:
getResources().getResourceEntryName(int resid);
Upvotes: 0