> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Enable Offline Support

> Turn on local caching and the durable send outbox, and verify offline support is active with the CometChat Android SDK.

> [accordion] AI Integration Quick Reference
>
> ```kotlin theme={null}
> // 1. Build an OfflineConfig (off by default — call enabled(true)).
> val offlineConfig = OfflineConfig.Builder()
>     .enabled(true)
>     .build()
>
> // 2. Attach it to AppSettings.
> val appSettings = AppSettings.AppSettingsBuilder()
>     .setRegion("REGION")
>     .setOfflineConfig(offlineConfig)   // explicit config; enabled value wins
>     // .offline(true)                  // shorthand: enable with all defaults
>     .build()
>
> // 3. Pass the settings to init.
> CometChat.init(context, "APP_ID", appSettings, callbackListener)
>
> // 4. Verify it is active for the logged-in user.
> val active = CometChat.isOfflineEnabled()   // Boolean
> ```

Offline support is **off by default**. You turn it on once, at initialization, by attaching an `OfflineConfig` to your `AppSettings`. Until you do, the SDK behaves exactly as before. This page covers the minimal setup; for every tunable option see the [Configuration & API Reference](https://www.cometchat.com/docs/sdk/android/v5/offline-reference.md).

**1. Requirements**

Offline support requires CometChat Android SDK **5.1.0** or later (minSdk 21). Add or update the dependency:

> [tab] Groovy
>
> ```groovy theme={null}
> implementation "com.cometchat:chat-sdk-android:5.1.0"
> ```

> [tab] Kotlin DSL
>
> ```kotlin theme={null}
> implementation("com.cometchat:chat-sdk-android:5.1.0")
> ```

If you are new to the SDK, complete the [standard setup](https://www.cometchat.com/docs/sdk/android/v5/setup.md) first; the steps below only add offline configuration to your existing `init`.

**2. Build an OfflineConfig**

Construct an `OfflineConfig` with its fluent `Builder` and call `enabled(true)`. Every other field has a sensible default, so set only what you need.

> [tab] Java
>
> ```java theme={null}
> OfflineConfig offlineConfig = new OfflineConfig.Builder()
>         .enabled(true)
>         .build();
> ```

> [tab] Kotlin
>
> ```kotlin theme={null}
> val offlineConfig = OfflineConfig.Builder()
>     .enabled(true)
>     .build()
> ```

**3. Attach it to AppSettings**

Pass the config to `AppSettingsBuilder.setOfflineConfig(...)`. To enable with all defaults instead of building a config, use the `offline(boolean)` shorthand.

> [tab] Java
>
> ```java theme={null}
> AppSettings appSettings = new AppSettings.AppSettingsBuilder()
>         .setRegion("REGION")
>         .setOfflineConfig(offlineConfig)   // explicit config
>         // .offline(true)                  // shorthand: enable with defaults
>         .build();
> ```

> [tab] Kotlin
>
> ```kotlin theme={null}
> val appSettings = AppSettings.AppSettingsBuilder()
>     .setRegion("REGION")
>     .setOfflineConfig(offlineConfig)       // explicit config
>     // .offline(true)                      // shorthand: enable with defaults
>     .build()
> ```

> [!NOTE]
>
> If you call both `setOfflineConfig(...)` and `offline(boolean)`, the explicit `OfflineConfig` wins — its `enabled` value is authoritative.

**4. Initialize the SDK**

Pass the settings to `CometChat.init(...)` as you do today. No other call changes.

> [tab] Java
>
> ```java theme={null}
> CometChat.init(context, "APP_ID", appSettings, new CometChat.CallbackListener<String>() {
>     @Override
>     public void onSuccess(String successMessage) {
>         Log.d(TAG, "Initialization completed successfully");
>     }
>
>     @Override
>     public void onError(CometChatException e) {
>         Log.e(TAG, "Initialization failed: " + e.getMessage());
>     }
> });
> ```

> [tab] Kotlin
>
> ```kotlin theme={null}
> CometChat.init(context, "APP_ID", appSettings, object : CometChat.CallbackListener<String>() {
>     override fun onSuccess(successMessage: String?) {
>         Log.d(TAG, "Initialization completed successfully")
>     }
>
>     override fun onError(e: CometChatException) {
>         Log.e(TAG, "Initialization failed: ${e?.message}")
>     }
> })
> ```

**5. Verify it is active**

Call `CometChat.isOfflineEnabled()`. It returns `true` only while offline support is actually active for the logged-in user. It is `false` before anyone logs in (even when you enabled it in `AppSettings`), after logout or session expiry, and when the encrypted cache cannot open. Read it at the moment of each decision and keep no copy of the result.

> [tab] Java
>
> ```java theme={null}
> boolean active = CometChat.isOfflineEnabled();
> Log.d(TAG, "Offline support active: " + active);
> ```

> [tab] Kotlin
>
> ```kotlin theme={null}
> val active = CometChat.isOfflineEnabled()
> Log.d(TAG, "Offline support active: $active")
> ```

## Next steps

Offline support is now active for the logged-in user. Continue with [Show Cached Data](https://www.cometchat.com/docs/sdk/android/v5/offline-cached-data.md) to adopt the new fetch listeners, and [Send While Offline](https://www.cometchat.com/docs/sdk/android/v5/offline-send.md) for the durable outbox. Tune caps, TTLs, media, and encryption from the [Configuration & API Reference](https://www.cometchat.com/docs/sdk/android/v5/offline-reference.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.