SDKsAndroid
Clear all saved messages
Use deleteAllMsgFromLocalAndSvr to clear local and server-side messages.
Clear all message records stored both in the local SQLite database and on the remote server for the logged-in account. This operation is permanent and irreversible; once executed, historical message data for the current account cannot be restored. This operation clears only the caller's message mailbox and does not delete message copies retained by other participants or alter friend and group relationships.
Code example
OpenIMClient.getInstance().messageManager.deleteAllMsgFromLocalAndSvr(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Local and server messages cleared successfully
}
@Override
public void onError(int code, String error) {
// Handle clearing failure
}
}
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback indicates that message records across all conversations were purged from both local storage and the server for this account. Clear open chat message views. - Conversation summary update: The last message preview (
latestMsg) on conversations is cleared or refreshed to reflect the empty state. - Re-query calibration: To delete only the local offline cache on this device while retaining cloud roaming history, call Clear all local messages.
Was this page helpful?