Browse SDKs · Android
Platform
SDKsAndroid

Delete a conversation and its messages

Remove a conversation from the conversation list and delete all associated messages using deleteConversationAndDeleteAllMsg().

Copy

Remove a conversation from the authenticated user's conversation list and permanently delete all associated historical messages. This corresponds to the user-initiated "Delete chat" action in a chat list.

Code example

OpenIMClient.getInstance().conversationManager.deleteConversationAndDeleteAllMsg(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Conversation and messages deleted successfully.
        }

        @Override
        public void onError(int code, String error) {
            // code and error describe the failure.
        }
    },
    conversationID
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
conversationIDStringYesTarget conversation identifier.

Return value

The successful callback indicates that both the server and local database completed the deletion of the conversation record and all its messages.

This operation removes records solely for the authenticated account; it does not terminate friendships, nor does it leave or dismiss groups. If a new message arrives in this conversation later, the SDK re-creates the conversation entry as a fresh thread.

State changes after the call

Upon deletion, the SDK dispatches the OnConversationListener.onConversationChanged event. Remove the item matching conversationID from your local list dataset and refresh the UI. For complete listener registration details, see Get the conversation list. To clear message history while keeping the conversation entry visible, see Clear messages in a conversation.