Using FirebaseRemoteConfig I am confused whether the setDefault method overwrites the cached Config values from the last fetch everytime we run it.
firebase, firebase-remote-config
Solution
Nope. `setDefaults` does not overwrite any previously fetched values you might have received from RemoteConfig.
From RemoteConfig's perspective, the "expiration time" does't mean that the previously fetched values are considered invalid. It just means that it's time for it to go out onto the network and see if any new values have appeared. If they haven't (or if it can't reach the network), RemoteConfig will keep whatever values it previously downloaded last time.
Problem
I am using a singleton Instance of the FirebaseRemoteConfig class which is generated using the following Provider method. ``` @Provides @Singleton FirebaseRemoteConfig provideFirebaseRemoteConfig() { final FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder() .setDeveloperModeEnabled(BuildConfig.DEBUG) .build(); mFirebaseRemoteConfig.setConfigSettings(configSettings); mFirebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults); long cacheExpiration = 3600 * 3; // 3 hours in seconds. if (mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) { cacheExpiration = 0; } mFirebaseRemoteConfig.fetch(cacheExpiration) .addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { // Once the config is successfully fetched it must be activated before newly fetched // values are returned. mFirebaseRemoteConfig.activateFetched(); } else { FirebaseCrash.log("RemoteConfig fetch failed at " +System.currentTimeMillis()); } } }); return mFirebaseRemoteConfig; } ``` Now the issue here is that if I am setting the setDefaults method everytime I am generating the singleton instance and since the last fetched config values have an expiration time, doesn't it mean that the Config values will revert to the initial defaultvalues hardcoded instead of picking up the last known config fetched. That is in case of inability to fetch from the server after the last fetched Config values expire. I tried looking at the Docs but there was no specific detail on how the whole caching works except for a simple overview. So people who have experience using RemoteConfig can easily answer this but I am using it for the first time so any help is appreciated.