@VisibleForTesting
  boolean isDbConsistent() {
    boolean result = true;
    Collection<String> tableColumnNames = listTableColumnNamesLowerCase();
    String[] expectedColumnNames = {
        ID_COLUMN,
        NAME_COLUMN,
        SECRET_COLUMN,
        COUNTER_COLUMN,
        TYPE_COLUMN,
        PROVIDER_COLUMN,
        ISSUER_COLUMN,
        ORIGINAL_NAME_COLUMN,
    };
    if (expectedColumnNames.length < tableColumnNames.size()) {
      Log.w(LOCAL_TAG, "Database has extra columns");
      // This doesn't mean the database is necessarily in a bad state
    }
    if (expectedColumnNames.length > tableColumnNames.size()) {
      Log.e(LOCAL_TAG, "Database is missing columns");
      result = false;
    }
    for (String columnName : expectedColumnNames) {
      if (!tableColumnNames.contains(columnName.toLowerCase(Locale.US))) {
        Log.e(LOCAL_TAG, "Database is missing column: " + columnName);
        result = false;
      }
    }

    for (AccountIndex index : getAccounts()) {
      Cursor cursor = mDatabase.query(
          TABLE_NAME, null, whereClause(index), null,
          null, null, null);
      try {
        if (cursor == null) {
          Log.e(LOCAL_TAG, "Failed to get a cursor for account: " + index.toString());
          result = false;
          continue;
        }
        if (cursor.getCount() != 1) {
          Log.e(LOCAL_TAG, "Multiple copies detected for account: " + index.toString());
          result = false;
        }
      } finally {
        tryCloseCursor(cursor);
      }
    }
    return result;
  }
@return whether the database appears to be consistent with expectations or not
java/com/google/android/apps/authenticator/otp/AccountDb.java