public List<AccountIndex> getAccounts() {
    Cursor cursor = mDatabase.query(TABLE_NAME, null, null, null, null, null, null, null);

    try {
      if (cursorIsEmpty(cursor)) {
        return ImmutableList.of();
      }

      int nameCount = cursor.getCount();
      int nameIndex = cursor.getColumnIndex(AccountDb.NAME_COLUMN);
      int issuerIndex = cursor.getColumnIndex(AccountDb.ISSUER_COLUMN);

      ImmutableList.Builder<AccountIndex> resultBuilder = ImmutableList.builder();
      for (int i = 0; i < nameCount; ++i) {
        cursor.moveToPosition(i);
        String name = cursor.getString(nameIndex);
        String issuer = null;
        if (issuerIndex >= 0) {
          issuer = cursor.getString(issuerIndex);
        }
        resultBuilder.add(new AccountIndex(name, issuer));
      }
      return resultBuilder.build();
    } finally {
      tryCloseCursor(cursor);
    }
  }
Lists the names of all accounts.
java/com/google/android/apps/authenticator/otp/AccountDb.java