public static void cleanOrphanedRecords() {
            withAccessLock(() -> {

                Log.d("Database clean: removing entries for non-existing caches from logs offline");
                database.delete(dbTableLogsOffline, "geocode NOT IN (SELECT geocode FROM " + dbTableCaches + ")", null);
                database.delete(dbTableLogsOfflineImages, "logoffline_id NOT IN (SELECT _id FROM " + dbTableLogsOffline + ")", null);
                database.delete(dbTableLogsOfflineTrackables, "logoffline_id NOT IN (SELECT _id FROM " + dbTableLogsOffline + ")", null);
            });
        }
if returned id is < 0 then there is no offline log for given geocode
main/src/main/java/cgeo/geocaching/storage/DataStore.java