Skip to content

🗝️ Preferences & DataStore Editor

Flocon provides full visibility into your app's key-value storage (SharedPreferences and Jetpack DataStore), allowing you to view and edit values live from the desktop UI.


Overview

Preferences UI

Features: - Auto-Discovery: Automatically finds and lists default SharedPreferences files on Android. - DataStore Support: Seamlessly browse and mutate PreferencesDataStore keys. - Live Mutation: Edit booleans, numbers, strings, and JSON objects in real-time.


Setup & Registration

dependencies {
    debugImplementation("io.github.openflocon:flocon-sharedprefs:LAST_VERSION")
    releaseImplementation("io.github.openflocon:flocon-sharedprefs-no-op:LAST_VERSION")
}

Install the plugin:

startFlocon(context) {
    install(FloconPreferences)
}

Standard SharedPreferences (Android)

All the SharedPreferences files of the app are automatically detected on Android. To register one with a custom display name:

val userPrefs = context.getSharedPreferences("user_pref", Context.MODE_PRIVATE)
Flocon.preferencesPlugin.register(FloconSharedPreference(name = "User Settings", userPrefs))

Jetpack DataStore

[libraries]
flocon-datastores = { module = "io.github.openflocon:flocon-datastores", version.ref = "flocon" }
flocon-datastores-no-op = { module = "io.github.openflocon:flocon-datastores-no-op", version.ref = "flocon" }
dependencies {
    debugImplementation("io.github.openflocon:flocon-datastores:LAST_VERSION")
    releaseImplementation("io.github.openflocon:flocon-datastores-no-op:LAST_VERSION")
}

Register your DataStore instance (Android, JVM and iOS):

val Context.dataStore by preferencesDataStore(name = "settings")

Flocon.preferencesPlugin.register(FloconDatastorePreference(name = "App Settings", context.dataStore))

If the values are encrypted, pass a FloconDatastoreMapper to decode / encode them:

FloconDatastorePreference(name = "Secure Settings", context.secureDataStore, mapper = myCipherMapper)

Custom Key-Value Storage

You can expose any proprietary storage system (such as EncryptedSharedPreferences or custom key-value stores, on every platform) by implementing FloconPreference:

class MyCustomPreference : FloconPreference {
    override val name: String = "Encrypted Vault"

    override suspend fun columns(): List<String> = listOf("token", "is_authenticated")

    override suspend fun get(columnName: String): FloconPreferenceValue? {
        return FloconPreferenceValue(stringValue = readSecureKey(columnName))
    }

    override suspend fun set(columnName: String, value: FloconPreferenceValue) {
        writeSecureKey(columnName, value.stringValue)
    }
}

Flocon.preferencesPlugin.register(MyCustomPreference())