private static void deleteOrphanedUDC() {
        final Set<String> orphanedUDC = new HashSet<>();
        queryToColl(dbTableCaches,
                new String[]{"geocode"},
                "SUBSTR(geocode,1," + InternalConnector.PREFIX.length() + ") = '" + InternalConnector.PREFIX + "' AND geocode NOT IN (SELECT geocode FROM " + dbTableCachesLists + " WHERE SUBSTR(geocode,1," + InternalConnector.PREFIX.length() + ") = '" + InternalConnector.PREFIX + "')",
                null,
                null,
                null,
                orphanedUDC,
                GET_STRING_0
        );
        final StringBuilder info = new StringBuilder();
        for (String geocode : orphanedUDC) {
            info.append(" ").append(geocode);
        }
        Log.i("delete orphaned UDC" + info);
        removeCaches(orphanedUDC, LoadFlags.REMOVE_ALL);
    }
Remove caches which are not on any list in the background. Once it has been executed once it will not do anything.
This must be called from the UI thread to ensure synchronization of an internal variable.
main/src/main/java/cgeo/geocaching/storage/DataStore.java