public static void moveDatabase(final Activity fromActivity) {
        final ProgressDialog dialog = ProgressDialog.show(fromActivity, fromActivity.getString(R.string.init_dbmove_dbmove), fromActivity.getString(R.string.init_dbmove_running), true, false);
        AndroidRxUtils.bindActivity(fromActivity, Observable.defer(() -> {
            if (!LocalStorage.isExternalStorageAvailable()) {
                Log.w("Database was not moved: external memory not available");
                return Observable.just(false);
            }
            return withChangeLock(() -> {

                closeDb();

                final File source = databasePath();
                final File target = databaseAlternatePath();
                if (!FileUtils.copy(source, target)) {
                    Log.e("Database could not be moved to " + target);
                    init();
                    return Observable.just(false);
                }
                if (!FileUtils.delete(source)) {
                    Log.e("Original database could not be deleted during move");
                }
                Settings.setDbOnSDCard(!Settings.isDbOnSDCard());
                Log.i("Database was moved to " + target);

                init();
                return Observable.just(true);
            });
        }).subscribeOn(Schedulers.io())).subscribe(success -> {
            dialog.dismiss();
            final String message = success ? fromActivity.getString(R.string.init_dbmove_success) : fromActivity.getString(R.string.init_dbmove_failed);
            SimpleDialog.of(fromActivity).setTitle(R.string.init_dbmove_dbmove).setMessage(TextParam.text(message)).show();
        });
    }
Move the database to/from external cgdata in a new thread,
showing a progress window
main/src/main/java/cgeo/geocaching/storage/DataStore.java