mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
mFirebaseRemoteConfig.activateFetched();
Map<String, String> map = getFirebaseRemoteMap(context,R.xml.defultValues);
//map contains all remote values
}
});
make sure you have defined all keys in the defaultValue file, After activateFetched success, you will able to dump all remote values
public Map<String, String> getFirebaseRemoteMap(Context context, @XmlRes int xmlRes) {
Map<String, String> stringStringMap = new HashMap<>();
XmlResourceParser xmlResourceParser = context.getResources().getXml(xmlRes);
try {
boolean isInKeyTag = false;
while (xmlResourceParser.getEventType() != XmlResourceParser.END_DOCUMENT) {
if (xmlResourceParser.getEventType() == XmlResourceParser.START_TAG) {
String tagName = xmlResourceParser.getName();
if (tagName.equals("key")) {
isInKeyTag = true;
}
}
if (xmlResourceParser.getEventType() == XmlResourceParser.END_TAG) {
String tagName = xmlResourceParser.getName();
if (tagName.equals("key")) {
isInKeyTag = false;
}
}
if (xmlResourceParser.getEventType() == XmlResourceParser.TEXT) {
if (isInKeyTag) {
String key = xmlResourceParser.getText();
FirebaseRemoteConfigValue val = FirebaseRemoteConfig.getInstance().getValue(key);
String s = val.asString();
stringStringMap.put(key, s);
}
}
xmlResourceParser.next();
}
return stringStringMap;
} catch (Exception e) {
return null;
}
}