If the key value pairs are not complex objects, best way is to store them in SharedPreferences.
Refer : https://stackoverflow.com/a/7944653/1594776
If they are complex, store it in the internal memory.
Refer : https://stackoverflow.com/a/7944773/1594776
If you still want to store it in xml, refer : https://stackoverflow.com/a/10196618/1594776
Function to parse the xml (Credits : https://stackoverflow.com/a/29856441/1594776) :
public static Map<String, String> getHashMapResource(Context context, int hashMapResId) {
Map<String, String> map = new HashMap<>();
XmlResourceParser parser = context.getResources().getXml(hashMapResId);
String key = null, value = null;
try {
int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("entry")) {
key = parser.getAttributeValue(null, "key");
if (null == key) {
parser.close();
return null;
}
}
}
else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("entry")) {
map.put(key, value);
key = null;
value = null;
}
} else if (eventType == XmlPullParser.TEXT) {
if (null != key) {
value = parser.getText();
}
}
eventType = parser.next();
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return map;
}