@Override
    public boolean onPreferenceStartFragment(@NonNull final PreferenceFragmentCompat caller, @NonNull final Preference pref) {
        // clear fragment backstack if new base category opened and in dualmode
        if (isInDualPaneMode() && caller instanceof PreferencesFragmentRoot) {
            while (getSupportFragmentManager().getBackStackEntryCount() > 0) {
                getSupportFragmentManager().popBackStackImmediate();
            }
        }
        // Instantiate the new Fragment
        final Bundle args = pref.getExtras();
        final Fragment fragment = getSupportFragmentManager()
                .getFragmentFactory()
                .instantiate(getClassLoader(), pref.getFragment());
        fragment.setArguments(args);
        fragment.setTargetFragment(caller, 0);
        // Replace the existing Fragment with the new Fragment
        getSupportFragmentManager().beginTransaction()
            .replace(preferenceContentView, fragment)
            .addToBackStack(null)
            .commit();
        title = pref.getTitle();
        return true;
    }
This method sets the fragment given by its base key,
and optionally starts scrolling to a preference identified by its key
main/src/main/java/cgeo/geocaching/settings/SettingsActivity.java