Browse SDKs · Android
SDKsAndroid

Clear all local messages

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

Copy

deleteAllMsgFromLocal() clears every message stored for the current account on this device. It does not delete server records or affect other devices or users. Explain this scope before running the operation.

OpenIMClient.getInstance().messageManager.deleteAllMsgFromLocal(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Clear message lists and related UI state for this account on this device.
        }

        @Override
        public void onError(int code, String error) {
            // Keep the existing UI state and report the failure.
        }
    }
);

The success callback means local deletion completed. This operation does not trigger message events on other clients, and messages retained by the server may be synchronized to this device again later.