Browse SDKs · Android
Platform
SDKsAndroid

Clear all local messages

Use deleteAllMsgFromLocal to clear all messages stored on the current device.

Copy

Clear all historical message records stored in the local database on the current device for the logged-in account. This operation does not issue a network request, does not alter cloud roaming history, and does not affect message records on other devices or peer accounts. It is recommended to display a confirmation prompt to the user before executing this action.

Code example

OpenIMClient.getInstance().messageManager.deleteAllMsgFromLocal(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Local messages cleared, reset active conversation timelines
        }

        @Override
        public void onError(int code, String error) {
            // Handle clearing failure
        }
    }
);

Parameters

ParameterTypeRequiredDescription
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 all local message data has been cleared from SQLite storage on this device. Clear active message timeline displays across all conversations.
  2. Local scope: This is a local-only operation that does not trigger network requests or broadcast events to other devices.
  3. Re-query calibration: Because server records remain intact, subsequent roaming history queries may retrieve previous messages from cloud storage. To delete messages from both local storage and the server across all devices, see Clear all saved messages.