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

# Android (Kotlin)

> Confidence Android SDK for feature flag evaluation in Kotlin and Java applications.

The Confidence Android SDK provides feature flag evaluation for Android applications. Flags resolve once according to the evaluation context, and values read from a local cache for fast access.

## Features

* **Local caching**: Flag values cached locally for instant access
* **OpenFeature compatible**: Standard feature flag API through OpenFeature provider
* **Automatic apply events**: Tracks flag assignments when your application reads flags
* **Custom event tracking**: Sends application events through the [OpenFeature Tracking API](https://openfeature.dev/specification/sections/tracking/)
* **Managed context**: Automatic visitor ID and opt-in device information context
* **Offline support**: Cached values available without network

<Note>
  Automatic apply events record flag assignments without explicit tracking calls. Custom tracking events are separate and require a call to the OpenFeature client's `track` method.
</Note>

## Installation

<Tabs>
  <Tab title="Gradle (Kotlin DSL)">
    ```kotlin theme={null}
    dependencies {
        implementation("com.spotify.confidence:openfeature-provider-android:<latest>")
    }
    ```
  </Tab>

  <Tab title="Gradle (Groovy)">
    ```groovy theme={null}
    dependencies {
        implementation 'com.spotify.confidence:openfeature-provider-android:<latest>'
    }
    ```
  </Tab>
</Tabs>

## Quickstart

```kotlin theme={null}
import com.spotify.confidence.ConfidenceFactory
import com.spotify.confidence.ConfidenceFeatureProvider
import com.spotify.confidence.ConfidenceRegion
import com.spotify.confidence.InitialisationStrategy
import dev.openfeature.sdk.OpenFeatureAPI

// Create the Confidence provider
val provider = ConfidenceFeatureProvider.create(
    ConfidenceFactory.create(
        context = applicationContext,
        clientSecret = "your-client-secret",
        region = ConfidenceRegion.EUROPE
    ),
    initialisationStrategy = InitialisationStrategy.FetchAndActivate
)

// Register with OpenFeature
OpenFeatureAPI.setProviderAndWait(provider)
val client = OpenFeatureAPI.getClient()

// Evaluate a flag
val message = client.getStringValue("flag-name.message", "default message")
println("Flag value: $message")

// Track a custom application event
client.track("checkout")
```

## Resources

<CardGroup cols={2}>
  <Card title="GitHub repository" icon="github" href="https://github.com/spotify/confidence-sdk-android">
    Source code, examples, and full documentation
  </Card>

  <Card title="OpenFeature Android SDK" icon="flag" href="https://openfeature.dev/docs/reference/technologies/client/android">
    OpenFeature documentation
  </Card>

  <Card title="Context" icon="sliders" href="/docs/reference/sdks/context">
    Configure evaluation context
  </Card>

  <Card title="Apply events" icon="chart-line" href="/docs/reference/sdks/apply-event">
    Understand flag assignment tracking
  </Card>
</CardGroup>
