public static int getAllStoredCachesCount(final int list) {
        if (list <= 0) {
            return 0;
        }

        return withAccessLock(() -> {

            init();

            try {
                final SQLiteStatement compiledStmnt;
                synchronized (PreparedStatement.COUNT_TYPE_LIST) {
                    // All the statements here are used only once and are protected through the current synchronized block
                    if (list == PseudoList.HISTORY_LIST.id) {
                        compiledStmnt = PreparedStatement.HISTORY_COUNT.getStatement();
                    } else if (list == PseudoList.ALL_LIST.id) {
                        compiledStmnt = PreparedStatement.COUNT_ALL_TYPES_ALL_LIST.getStatement();
                    } else {
                        compiledStmnt = PreparedStatement.COUNT_ALL_TYPES_LIST.getStatement();
                        compiledStmnt.bindLong(1, list);
                    }

                    return (int) compiledStmnt.simpleQueryForLong();
                }
            } catch (final Exception e) {
                Log.e("DataStore.loadAllStoredCachesCount", e);
            }

            return 0;
        });
    }
Number of caches stored for a given type and/or list
main/src/main/java/cgeo/geocaching/storage/DataStore.java