The remote config module delivers key-value pairs from the AppDNA Console to your app. Values are set in the Console and synced to the SDK automatically. All reads are synchronous from an in-memory cache — they never block the main thread or require a network call.
Get Config Values
Read values using typed getters. Each method accepts a default value that is returned when the key does not exist or the config has not loaded yet.
val welcome = AppDNA.remoteConfig.getString("welcome_message", default = "Hello!")
val maxRetries = AppDNA.remoteConfig.getInt("max_retries", default = 3)
val discount = AppDNA.remoteConfig.getDouble("discount_rate", default = 0.1)
val promoEnabled = AppDNA.remoteConfig.getBool("show_promo", default = false)
For complex values, use getJSON to retrieve a map:
val bannerConfig = AppDNA.remoteConfig.getJSON("hero_banner")
// Returns Map<String, Any>? -- null if key not found
Module Access
val remoteConfig = AppDNA.remoteConfig
Module Methods
| Method | Signature | Description |
|---|
getString | getString(key: String, default: String): String | Get a string value |
getInt | getInt(key: String, default: Int): Int | Get an integer value |
getDouble | getDouble(key: String, default: Double): Double | Get a double value |
getBool | getBool(key: String, default: Boolean): Boolean | Get a boolean value |
getJSON | getJSON(key: String): Map<String, Any>? | Get a JSON map |
getAllKeys | getAllKeys(): List<String> | List all available config keys |
When Config Refreshes
The SDK refreshes remote config automatically:
- On app launch — if the cached config has expired (default TTL: 5 minutes)
- On return from background — same TTL check
- Background fetch — the SDK checks for updates periodically
You never need to trigger a refresh manually. If the fetch fails (no connectivity, timeout), the SDK continues using the cached values.
The config TTL is configurable via AppDNAOptions(configTTL = 600) (in seconds). The default is 300 seconds (5 minutes).
Listen for Config Changes
Register a delegate to be notified when remote config values change after a background refresh:
AppDNA.remoteConfig.delegate = object : RemoteConfigDelegate {
override fun onConfigUpdated(updatedKeys: List<String>) {
if ("show_promo" in updatedKeys) {
val show = AppDNA.remoteConfig.getBool("show_promo", default = false)
updatePromoBanner(visible = show)
}
}
}
Full Example
import ai.appdna.sdk.AppDNA
import ai.appdna.sdk.RemoteConfigDelegate
class HomeActivity : AppCompatActivity(), RemoteConfigDelegate {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
AppDNA.remoteConfig.delegate = this
configureUI()
}
private fun configureUI() {
val title = AppDNA.remoteConfig.getString("home_title", default = "Welcome")
val showBanner = AppDNA.remoteConfig.getBool("show_promo_banner", default = false)
val bannerText = AppDNA.remoteConfig.getString("promo_banner_text", default = "")
titleView.text = title
if (showBanner) {
promoBanner.text = bannerText
promoBanner.visibility = View.VISIBLE
}
}
// RemoteConfigDelegate
override fun onConfigUpdated(updatedKeys: List<String>) {
runOnUiThread { configureUI() }
}
}
Remote config values are managed in the Console under Settings > Remote Config. Changes take effect on the next SDK config refresh (within the TTL window).