Browse SDKs · Android
Platform
SDKsAndroid

Delete a local message

Use deleteMessageFromLocalStorage to delete only the message copy on the current device.

Copy

Delete a single message record exclusively from the local SQLite storage on the current device. This operation does not issue a network request to the server, does not alter cloud roaming history, and does not synchronize to other client devices logged into the same account or to chat peers.

Code example

String conversationID = "si_user_a_user_b";
String clientMsgID = "msg_001";

OpenIMClient.getInstance().messageManager.deleteMessageFromLocalStorage(
    conversationID,
    clientMsgID,
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Local deletion succeeded, remove message from UI timeline
        }

        @Override
        public void onError(int code, String error) {
            // Failed to delete message from local storage
        }
    }
);

Parameters

ParameterTypeRequiredDescription
conversationIDStringYesGlobally unique ID of the target conversation.
clientMsgIDStringYesClient message ID of the message to delete.
baseOnBase<String>YesCallback handler for the asynchronous request.

Return value

Upon success, data in onSuccess returns a confirmation message.

State changes after the call

  1. Callback confirmation: The onSuccess callback confirms that the record was removed from the local database on this device.
  2. Local scope: This is a local-only operation that does not trigger network events or synchronization listeners.
  3. Re-query behavior: If the conversation history is later refetched from the server via Load older messages, the message may reappear because it remains in cloud storage. To delete messages from both local storage and the server across all devices, call Delete messages in a batch.