public static void removeCaches(final Set<String> geocodes, final EnumSet<LoadFlags.RemoveFlag> removeFlags) {
        if (CollectionUtils.isEmpty(geocodes)) {
            return;
        }

        withAccessLock(() -> {


            init();

            if (removeFlags.contains(RemoveFlag.CACHE)) {
                for (final String geocode : geocodes) {
                    cacheCache.removeCacheFromCache(geocode);
                }
            }

            if (removeFlags.contains(RemoveFlag.DB)) {
                // Drop caches from the database
                final ArrayList<String> quotedGeocodes = new ArrayList<>(geocodes.size());
                for (final String geocode : geocodes) {
                    quotedGeocodes.add(DatabaseUtils.sqlEscapeString(geocode));
                }
                final String geocodeList = StringUtils.join(quotedGeocodes.toArray(), ',');
                final String baseWhereClause = "geocode IN (" + geocodeList + ")";
                database.beginTransaction();
                try {
                    database.delete(dbTableCaches, baseWhereClause, null);
                    database.delete(dbTableAttributes, baseWhereClause, null);
                    database.delete(dbTableSpoilers, baseWhereClause, null);
                    database.delete(dbTableLogImages, "log_id IN (SELECT _id FROM " + dbTableLogs + " WHERE " + baseWhereClause + ")", null);
                    database.delete(dbTableLogs, baseWhereClause, null);
                    database.delete(dbTableLogCount, baseWhereClause, null);
                    DBLogOfflineUtils.remove(baseWhereClause, null);
                    String wayPointClause = baseWhereClause;
                    if (!removeFlags.contains(RemoveFlag.OWN_WAYPOINTS_ONLY_FOR_TESTING)) {
                        wayPointClause += " AND type <> 'own'";
                    }
                    database.delete(dbTableWaypoints, wayPointClause, null);
                    database.delete(dbTableVariables, baseWhereClause, null);
                    database.delete(dbTableCategories, baseWhereClause, null);
                    database.delete(dbTableTrackables, baseWhereClause, null);
                    database.setTransactionSuccessful();
                } finally {
                    database.endTransaction();
                }

                // Delete cache directories
                for (final String geocode : geocodes) {
                    FileUtils.deleteDirectory(LocalStorage.getGeocacheDataDirectory(geocode));
                }
            }
        });
    }
Drop caches from the tables they are stored into, as well as the cache files

@param geocodes list of geocodes to drop from cache
main/src/main/java/cgeo/geocaching/storage/DataStore.java