<NME> PreferenceOfflinedataFragment.java
<BEF> package cgeo.geocaching.settings.fragments;

import cgeo.geocaching.R;
import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.settings.SettingsActivity;
import static cgeo.geocaching.utils.SettingsUtils.initPublicFolders;

import android.os.Bundle;

import androidx.preference.PreferenceFragmentCompat;

public class PreferenceOfflinedataFragment extends PreferenceFragmentCompat {
    @Override
    public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
        setPreferencesFromResource(R.xml.preferences_offlinedata, rootKey);

        // TODO
        findPreference(getString(R.string.pref_fakekey_dataDir)).setSummary(Settings.getExternalPrivateCgeoDirectory());
    }
            waitDialog.setTitle(getString(R.string.init_maintenance_start));
            waitDialog.setMessage(getString(R.string.init_maintenance_ongoing));
            waitDialog.setCancelable(false);
            waitDialog.show();

            AndroidRxUtils.andThenOnUi(Schedulers.io(), DataStore::removeObsoleteGeocacheDataDirectories, () -> {
                final Activity activity = getActivity();
                if (activity != null) {
                    ActivityMixin.showShortToast(activity, R.string.init_maintenance_finished);
                }
                waitDialog.dismiss();
            });
            return true;
        });

        final Preference isDbOnSdCard = findPreference(getString(R.string.pref_dbonsdcard));
        isDbOnSdCard.setPersistent(false);
        isDbOnSdCard.setOnPreferenceClickListener(preference -> {
            final boolean oldValue = Settings.isDbOnSDCard();
            DataStore.moveDatabase(getActivity());
            return oldValue != Settings.isDbOnSDCard();
        });

        final Preference dataDirPreference = findPreference(getString(R.string.pref_fakekey_dataDir));
        dataDirPreference.setSummary(Settings.getExternalPrivateCgeoDirectory());
        if (LocalStorage.getAvailableExternalPrivateCgeoDirectories().size() < 2) {
            dataDirPreference.setEnabled(false);
        } else {
            final AtomicLong usedBytes = new AtomicLong();
            dataDirPreference.setOnPreferenceClickListener(preference -> {
                final ProgressDialog progress = ProgressDialog.show(getActivity(), getString(R.string.calculate_dataDir_title), getString(R.string.calculate_dataDir), true, false);
                AndroidRxUtils.andThenOnUi(Schedulers.io(), () -> {
                    // calculate disk usage
                    usedBytes.set(FileUtils.getSize(LocalStorage.getExternalPrivateCgeoDirectory()));
                }, () -> {
                    progress.dismiss();
                    SettingsUtils.showExtCgeoDirChooser(this, usedBytes.get());
                });
                return true;
            });
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        final SettingsActivity activity = (SettingsActivity) getActivity();
        assert activity != null;
        activity.setTitle(R.string.settings_title_offlinedata);
        SettingsUtils.initPublicFolders(this, activity.getCsah());
    }
}

<MSG> restore maintenance method (fix #12267)

<DFF> @@ -1,19 +1,32 @@
 package cgeo.geocaching.settings.fragments;
 
 import cgeo.geocaching.R;
+import cgeo.geocaching.activity.ActivityMixin;
 import cgeo.geocaching.settings.Settings;
 import cgeo.geocaching.settings.SettingsActivity;
+import cgeo.geocaching.storage.DataStore;
+import cgeo.geocaching.utils.AndroidRxUtils;
 import static cgeo.geocaching.utils.SettingsUtils.initPublicFolders;
 
 import android.os.Bundle;
 
 import androidx.preference.PreferenceFragmentCompat;
 
+import io.reactivex.rxjava3.schedulers.Schedulers;
+
 public class PreferenceOfflinedataFragment extends PreferenceFragmentCompat {
     @Override
     public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
         setPreferencesFromResource(R.xml.preferences_offlinedata, rootKey);
 
+        findPreference(getString(R.string.pref_fakekey_preference_maintenance_directories)).setOnPreferenceClickListener(preference -> {
+            // disable the button, as the cleanup runs in background and should not be invoked a second time
+            preference.setEnabled(false);
+            ActivityMixin.showShortToast(getActivity(), R.string.init_maintenance_start);
+            AndroidRxUtils.andThenOnUi(Schedulers.io(), DataStore::removeObsoleteGeocacheDataDirectories, () -> ActivityMixin.showShortToast(getActivity(), R.string.init_maintenance_finished));
+            return true;
+        });
+
         // TODO
         findPreference(getString(R.string.pref_fakekey_dataDir)).setSummary(Settings.getExternalPrivateCgeoDirectory());
     }

restore maintenance method (fix #12267)