
Wraps MMKV library, offering efficient cross-platform data storage with initialization, data type storage, retrieval, and collection operations. Supports instance management for seamless integration across operating systems.
MMKV-Kotlin-Multiplatform-Binding (abbreviated as MKMB) is a Kotlin Multiplatform wrapper for MMKV, providing high-performance key-value storage across multiple platforms.
Add the core module to your project:
dependencies {
implementation("top.kagg886.mkmb:core:${latest_version}")
}Desktop platforms require platform-specific native libraries. Requires Java 22+ (uses Project Panama for FFI).
kotlin {
sourceSets {
jvmMain.dependencies {
// Choose the platform library that matches your OS:
implementation("top.kagg886.mkmb:platform-windows:${latest_version}") // Windows
implementation("top.kagg886.mkmb:platform-linux:${latest_version}") // Linux
implementation("top.kagg886.mkmb:platform-macos:${latest_version}") // macOS
// Or detect at runtime:
val platform = when {
System.getProperty("os.name") == "Mac OS X" -> "macos"
System.getProperty("os.name").startsWith("Win") -> "windows"
System.getProperty("os.name").startsWith("Linux") -> "linux"
else -> error("Unsupported OS")
}
implementation("top.kagg886.mkmb:platform-${platform}:${latest_version}")
}
}
}Android and iOS platform binaries are automatically included with the core module. No additional dependencies needed.
For enhanced features like Kotlin Flow support, typed accessors, and more:
dependencies {
implementation("top.kagg886.mkmb:ext:${latest_version}")
}// 1. Initialize once at app startup
MMKV.initialize("/path/to/storage")
// 2. Get an instance
val kv = MMKV.defaultMMKV()
// 3. Store and retrieve values
kv.set("key", "value")
val value = kv.getString("key")For complete API documentation, visit mmkv.kagg886.top
defaultMMKV, mmkvWithID)Int, Long, Float, Double, Boolean, String, ByteArray, List<String>
remove, clear, exists, allKeys, size
destroy, isAlive
Parcelable storage, SharedPreferences migrationNSCoding object storageflow<T>(key)
import top.kagg886.mkmb.MMKV
import top.kagg886.mkmb.MMKVMode
// Initialize
MMKV.initialize("/data/mmkv") {
logLevel = MMKVOptions.LogLevel.Info
}
// Basic usage
val kv = MMKV.defaultMMKV()
kv.set("count", 42)
println(kv.getInt("count")) // 42
// With encryption
val encrypted = MMKV.mmkvWithID("secure", cryptKey = "my-secret-key")
encrypted.set("password", "p@ssw0rd")
// Multi-process
val shared = MMKV.mmkvWithID("shared", mode = MMKVMode.MULTI_PROCESS)See LICENSE
MMKV-Kotlin-Multiplatform-Binding (abbreviated as MKMB) is a Kotlin Multiplatform wrapper for MMKV, providing high-performance key-value storage across multiple platforms.
Add the core module to your project:
dependencies {
implementation("top.kagg886.mkmb:core:${latest_version}")
}Desktop platforms require platform-specific native libraries. Requires Java 22+ (uses Project Panama for FFI).
kotlin {
sourceSets {
jvmMain.dependencies {
// Choose the platform library that matches your OS:
implementation("top.kagg886.mkmb:platform-windows:${latest_version}") // Windows
implementation("top.kagg886.mkmb:platform-linux:${latest_version}") // Linux
implementation("top.kagg886.mkmb:platform-macos:${latest_version}") // macOS
// Or detect at runtime:
val platform = when {
System.getProperty("os.name") == "Mac OS X" -> "macos"
System.getProperty("os.name").startsWith("Win") -> "windows"
System.getProperty("os.name").startsWith("Linux") -> "linux"
else -> error("Unsupported OS")
}
implementation("top.kagg886.mkmb:platform-${platform}:${latest_version}")
}
}
}Android and iOS platform binaries are automatically included with the core module. No additional dependencies needed.
For enhanced features like Kotlin Flow support, typed accessors, and more:
dependencies {
implementation("top.kagg886.mkmb:ext:${latest_version}")
}// 1. Initialize once at app startup
MMKV.initialize("/path/to/storage")
// 2. Get an instance
val kv = MMKV.defaultMMKV()
// 3. Store and retrieve values
kv.set("key", "value")
val value = kv.getString("key")For complete API documentation, visit mmkv.kagg886.top
defaultMMKV, mmkvWithID)Int, Long, Float, Double, Boolean, String, ByteArray, List<String>
remove, clear, exists, allKeys, size
destroy, isAlive
Parcelable storage, SharedPreferences migrationNSCoding object storageflow<T>(key)
import top.kagg886.mkmb.MMKV
import top.kagg886.mkmb.MMKVMode
// Initialize
MMKV.initialize("/data/mmkv") {
logLevel = MMKVOptions.LogLevel.Info
}
// Basic usage
val kv = MMKV.defaultMMKV()
kv.set("count", 42)
println(kv.getInt("count")) // 42
// With encryption
val encrypted = MMKV.mmkvWithID("secure", cryptKey = "my-secret-key")
encrypted.set("password", "p@ssw0rd")
// Multi-process
val shared = MMKV.mmkvWithID("shared", mode = MMKVMode.MULTI_PROCESS)See LICENSE