Skip to main content
This page is the full surface of CometChat’s offline support on Android: configuration options, public methods, listeners, enums, model fields, and error codes. The minimum SDK version is 5.1.0, and offline support is off by default. For task-focused guides see Enable Offline Support, Show Cached Data, Send While Offline, Stay in Sync, Media Caching, and Encrypt the Cache.

OfflineConfig options

Build with OfflineConfig.Builder. Every field is pre-set to its default, so call only the setters you want to change; the resulting OfflineConfig is immutable. Byte caps and the TTL treat <= 0 as unlimited (that dimension’s eviction is disabled); the count caps are clamped and have no “unlimited”. Each default and upper limit is also available as a constant on OfflineConfig (DEFAULT_MAX_CONVERSATIONS, MAX_PENDING_MESSAGES, and so on). Attach the config at init via AppSettings.AppSettingsBuilder.setOfflineConfig(OfflineConfig), or enable with defaults via the offline(boolean) shorthand — see Enable Offline Support.

Public methods on CometChat

On the returned UploadFileRequest, getItems() lists each file’s UploadFileItemStatus, and retryAttachment(String fileId) (optionally with an UploadFileListener) retries one failed file. New batches are created with CometChat.createUploadFileRequest; see Upload Files.

Listener registration

MessageFetchListener, MessageSentListener, SyncListener and OfflineMessageListener are nested abstract classes on CometChat (e.g. CometChat.SyncListener). OfflineCacheResetListener is a top-level abstract class in com.cometchat.chat.core. MediaCallbackListener and MediaDownloadListener are top-level interfaces in com.cometchat.chat.models.

Listeners and callbacks

Two-phase fetch listeners

Each delivers the cached page first (when offline is active and a user is logged in), then the server result, then errors. With offline off the cached callback never fires.

Send, sync, cache, and media listeners

Enums

Model fields

Error codes

Compare CometChatException.getCode() against these codes. All are constants in CometChatConstants.Errors except ERROR_PENDING_QUEUE_LIMIT, ERROR_OFFLINE_MESSAGE_PERSIST_FAILED, ERROR_OFFLINE_MEDIA_COPY_FAILED, ERROR_MEDIA_UNAVAILABLE and ERROR_MEDIA_DOWNLOAD_FAILED, which you compare as string values.

Deprecated overloads and replacements

Starting in 5.1.0 the legacy single-callback (CallbackListener) fetch, single-item, and send overloads are deprecated in favor of the two-phase listeners below, which also deliver the cached result when offline support is on. The old overloads keep working: with offline off they behave exactly as before (the server result arrives in the onServer… / onMessageSent callback instead of onSuccess).