code: private void restoreDefaults(@NonNull final PreferenceGroup preferenceGroup,
                                   @NonNull final SharedPreferences sharedPreferences) {
          for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) {
              Preference preference = preferenceGroup.getPreference(i);
  
              if (preference instanceof PreferenceGroup) {
                  restoreDefaults((PreferenceGroup) preference, sharedPreferences);
              } else if (preference.getKey() != null && !preference.getKey().isEmpty()) {
                  Object oldValue = sharedPreferences.getAll().get(preference.getKey());
  
                  if (notifyOnRestoreDefaultValueRequested(preference, oldValue)) {
                      sharedPreferences.edit().remove(preference.getKey()).apply();
                      preferenceGroup.removePreference(preference);
                      preferenceGroup.addPreference(preference);
                      Object newValue = sharedPreferences.getAll().get(preference.getKey());
                      notifyOnRestoredDefaultValue(preference, oldValue, newValue);
                  } else {
                      preferenceGroup.removePreference(preference);
                      preferenceGroup.addPreference(preference);
                  }
  
              }
          }
      }
docs: Restores the default preferences, which are contained by a specific preference group.
  
  @param preferenceGroup
  The preference group, whose preferences should be restored, as an instance of the
  class {@link PreferenceGroup}. The preference group may not be null
  @param sharedPreferences
  The shared preferences, which should be used to restore the preferences, as an
  instance of the type {@link SharedPreferences}. The shared preferences may not be
  null