Set up Firebase Remote Config

You can use Firebase Remote Config to define parameters in your app and update their values in the cloud, allowing you to modify the appearance and behavior of your app without distributing an app update.

Connect your app to Firebase

  1. Install the Firebase SDK.
  2. In the Firebase console, add your app to your Firebase project.

Add Remote Config to your app

Add the dependency for Remote Config to your app-level build.gradle file:

implementation ''

Create the singleton Remote Config object, as shown in the following example:

mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();

This object is used to store in-app default parameter values, fetch updated parameter values from the service, and control when fetched values are made available to your app. To learn more, see Remote Config API Overview.

Set in-app default parameter values

You can set in-app default parameter values in the Remote Config object, so that your app behaves as intended before it connects to the Remote Config Server, and so that default values are available if none are set in the service.

Define a set of parameter names, and default parameter values using a Map object or an XML resource file stored in your app's res/xml folder.

<?xml version="1.0" encoding="utf-8"?>
<!-- START xml_defaults -->
        <value>Fetching config…</value>
        <value>Welcome to my awesome app!</value>
    <!-- END xml_defaults -->

Add these values to the Remote Config object using setDefaults().


Note: At this point, your app can use in-app default parameter values. To use in-app default values, skip the next section. You can deploy your app without setting parameter values in the service, and then later set values in the service to override the default behavior and appearance of your app.

Set parameter values in the service (as needed)

  1. In the Firebase console, open your project.
  2. Select Remote Config from the menu to view the Remote Config dashboard.
  3. Define parameters with the same names as the parameters that you defined in your app. For each parameter, you can set a default value (which will eventually override the in-app default value) and you can also set conditional values. To learn more, see Remote Config Parameters and Conditions.

Fetch and activate values from the service

To fetch parameter values from the Remote Config Server, call the fetch() method. Any values that you set on the Remote Config Server are fetched and cached in the Remote Config object.

If your fetch was successful, call the activateFetched() method to make the values available to your app.

Note: Fetching and activating values from the Remote Config Server is efficient and can be done safely and repeatedly, with a negligible impact on performance. This is true whether or not there are parameter values available on the Remote Config Server.

// cacheExpirationSeconds is set to cacheExpiration here, indicating the next fetch request
// will use fetch data from the Remote Config service, rather than cached parameter values,
// if cached parameter values are more than cacheExpiration seconds old.
// See Best Practices in the README for more information.
        .addOnCompleteListener(this, new OnCompleteListener<Void>() {
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    Toast.makeText(MainActivity.this, "Fetch Succeeded",

                    // After config data is successfully fetched, it must be activated before newly fetched
                    // values are returned.
                } else {
                    Toast.makeText(MainActivity.this, "Fetch Failed",

Because these updated parameter values affect the behavior and appearance of your app, you should activate the fetched values at a time that ensures a smooth experience for your user, such as the next time that the user opens your app.

Get parameter values to use in your app

Now you can get parameter values from the FirebaseRemoteConfig object using the various get methods.

String welcomeMessage = mFirebaseRemoteConfig.getString(WELCOME_MESSAGE_KEY);

Next Steps

Learn how to run experiments by using Remote Config with Analytics

Send feedback about...

Need help? Visit our support page.