In my values.xml, I have some string resources. But sometimes, I want to have a null value for that string resource for specific reasons.
How do I specify that string to have a null
value?
values.xml:
<string name="default_item_0">Some String</string>
<string name="default_item_1">@null</string>
Java code:
String item0 = context.getString(R.string.default_item_0);
String item1 = context.getString(R.string.default_item_1);
Expected:
String item0 = "Some String";
String item1 = null;
Actual:
String item0 = "Some String";
String item1 = "@0";
I tried the @null value, but it returns a string of @0
instead.
Is it possible to have a null
value in xml?