SDKsAndroid
Set local message extensions
Use setMessageLocalEx to store message data used only on the current device.
Save device-specific custom extension data (localEx) for a designated message on the current device. This is suitable for caching local file download states, media playback timestamps, audio transcription text caches, or custom UI display attributes. The stored data remains strictly local and is never synchronized to the server or other client devices.
Code example
String conversationID = "si_user_a_user_b";
String clientMsgID = "msg_001";
String localExJson = "{\"downloadStatus\":2,\"localPath\":\"/storage/emulated/0/...\"}";
OpenIMClient.getInstance().messageManager.setMessageLocalEx(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Local extension saved successfully
}
@Override
public void onError(int code, String error) {
// Handle save failure
}
},
conversationID,
clientMsgID,
localExJson
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
conversationID | String | Yes | Globally unique ID of the conversation containing the message. |
clientMsgID | String | Yes | Client message ID of the target message. |
localEx | String | Yes | Custom extension string (typically formatted as JSON). |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback confirms thatlocalExwas updated in the local database. Update thelocalExproperty on the in-memory message instance usingclientMsgIDand refresh the UI item. - Local scope: This operation writes strictly to local storage. It does not alter message body content on the server and does not trigger real-time events on other clients.
- Re-query calibration: The extension persists only in local storage on this device and will not be present if the message is re-fetched from cloud roaming history on another device.
Was this page helpful?