private static synchronized void closeDb() {
        if (!databaseLock.isWriteLockedByCurrentThread()) {
            throw new IllegalStateException("Trying to close DB w/o write lock");
        }

        if (database == null) {
            return;
        }

        cacheCache.removeAllFromCache();
        PreparedStatement.clearPreparedStatements();
        database.close();
        database = null;
    }
Attempt to recreate the database if opening has failed

@param dbHelper dbHelper to use to reopen the database
@return null if everything is ok, error message otherwise
main/src/main/java/cgeo/geocaching/storage/DataStore.java