Browse SDKs · Android
SDKsAndroid

Delete a conversation and its messages

Use deleteConversationAndDeleteAllMsg() to delete a conversation and its messages.

Copy

deleteConversationAndDeleteAllMsg() deletes a conversation and all of its messages.

OpenIMClient.getInstance().conversationManager.deleteConversationAndDeleteAllMsg(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // The request completed and the conversation and messages were deleted.
        }

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

After success, clear the current message list and conversation row. This does not delete a friend relationship or leave or dismiss a group. A conversation can be regenerated by a new message or synchronization while the chat target still exists. To update the conversation list, query conversations again or receive changes through onConversationChanged; see Get the conversation list for listener setup.