public boolean rename(AccountIndex oldIndex, String newName) {
    Preconditions.checkNotNull(oldIndex);
    Preconditions.checkNotNull(oldIndex.getName());
    Preconditions.checkNotNull(newName);

    if (oldIndex.getName().equals(newName)) {
      // Nothing to do
      return true;
    }

    if (GOOGLE_CORP_ACCOUNT_NAME.equals(oldIndex.getName())) {
      // Renaming the Google corp OTP account breaks reseeding and is thus not supported
      throw new UnsupportedOperationException();
    }

    if (indexExists(new AccountIndex(newName, oldIndex.getIssuer()))) {
      // Don't overwrite an existing account
      return false;
    }

    ContentValues values = new ContentValues();
    values.put(NAME_COLUMN, newName);
    int affectedRows = mDatabase.update(TABLE_NAME, values, whereClause(oldIndex), null);
    if (affectedRows > 1) {
      Log.wtf(LOCAL_TAG, "Unexpectedly changed multiple rows during rename. Database consistent: " +
          isDbConsistent());
    }
    return affectedRows > 0;
  }
Renames the specified account.

@return {@code true} if the operation succeeded, {@code false} otherwise (e.g., an account
    with {@code newName} and the same {@code issuer} already exists).
java/com/google/android/apps/authenticator/otp/AccountDb.java