Tencent /MMKV
An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, POSIX, and OHOS.
★ 18,774⑂ 1,997👁 284⑃ 401● 1,197▤ 64
-2
Daily
+1
Weekly
+11
Monthly
18,774
stars
1,997
forks
284
watchers
401
prs
1,197
issues
64
releases
README
中文版本请参看这里
MMKV is an efficient, small, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on Android, iOS/macOS, Windows, POSIX and HarmonyOS NEXT, with experimental Kotlin Multiplatform support.
MMKV for Kotlin Multiplatform
The v2.4.3 Kotlin Multiplatform package is experimental and currently targets
Android and iOS. Its API and artifact layout may change in a future release.
Add it to the shared module:
kotlin
kotlin {
sourceSets {
commonMain.dependencies {
implementation("com.tencent:mmkv-kmp:2.4.3")
}
}
}
Supported targets are Android, iosArm64, iosSimulatorArm64, and iosX64. See the Kotlin Multiplatform guide for initialization and packaging details.
MMKV for Android
Features
Efficient. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of Android to achieve the best performance.
Multi-Process concurrency: MMKV supports concurrent read-read and read-write access between processes.
Easy-to-use. You can use MMKV as you go. All changes are saved immediately, no sync, no apply calls needed.
Small.
A handful of files: MMKV contains process locks, encode/decode helpers and mmap logics, and nothing more. It's really tidy.
About 50K in binary size: MMKV adds about 50K per architecture on App size, and much less when zipped (APK).
Getting Started
Installation Via Maven
Add the following lines to build.gradle on your app module:
gradle
dependencies {
implementation 'com.tencent:mmkv:2.4.3'
// replace "2.4.3" with any available version
}
Starting from v2.0.0, MMKV no longer supports 32-bit arch and API level 22 or 21, if you want 32-bit or API level 21~22, use v1.3.x LTS series.
For other installation options, see Android Setup.
Quick Tutorial
You can use MMKV as you go. All changes are saved immediately, no sync, no apply calls needed.
Setup MMKV on App startup, say your Application class, add these lines:
Java
public void onCreate() {
super.onCreate();
String rootDir = MMKV.initialize(this);
System.out.println("mmkv root: " + rootDir);
//……
}
MMKV has a global instance, that can be used directly:
Java
import com.tencent.mmkv.MMKV;
MMKV kv = MMKV.defaultMMKV();
kv.encode("bool", true);
boolean bValue = kv.decodeBool("bool");
kv.encode("int", Integer.MIN_VALUE);
int iValue = kv.decodeInt("int");
kv.encode("string", "Hello from mmkv");
String str = kv.decodeString("string");
MMKV also supports Multi-Process Access. Full tutorials can be found here Android Tutorial.
Performance
Writing random int for 1000 times, we get this chart:
!
For more benchmark data, please refer to our benchmark.
MMKV for iOS/macOS
Features
Efficient. MMKV uses mmap to keep memory synced with files, and protobuf to encode/decode values, making the most of iOS/macOS to achieve theTop issues
#1707Apple MMKVCore allKeys() truncates keys at embedded NUL bytes2 comments · 2026-11-12#1706Swift Package Manager Support: Add FlutterFramework Dependency2 comments · 2026-11-07#1698t_status is a process-wide global on Apple platforms, so concurrent writes to two encrypted instances can lose every key2 comments · 2026-10-21
Discussions
#1685flutter_mmkv 如何查看mmkv中存储的数据啊?类似前端浏览器一样可以在开发工具中看到1 comments · 2026-08-28#1670mmkv-go — a cgo-free, read-only MMKV reader in pure Go (zero-alloc, ~10–75× faster reads)1 comments · 2026-06-09#1655Is latest version of MMKV for android app 16kb Page Size compatible?1 comments · 2026-03-31#1651iOS有遇到过[MMKV.defaultMMKV setBool:value forKey:key] 不生效的问题吗?1 comments · 2026-03-24#1637MMKV是否支持多个App之间的通信1 comments · 2026-01-28#1636一个mmkv文件中key太多会影响读写的性能吗?1 comments · 2026-01-27#1631支持SPM1 comments · 2026-01-11#1584About UnsupportedArchitectureException Bug1 comments · 2025-09-11
Latest release
v2.4.3 v2.4.3 2026-10-16v2.4.3 / 2026-10-16 This is a bugfix release based on v2.4.2, focused on encryption, expiration, imports, and file recovery. It also adds Android KMP initialization without an explicit Context and non-expired-key enumeration on Apple platforms. Upcoming compatibility change: The release after v2.4.3 will raise the minimum supported versions from iOS 13.0 to iOS 15.0 and from watchOS 6.0 to watchOS 9.0, to align with Xcode 27's supported deployment targets. The minimum deployment targets in v2.4.3 remain unchanged. Changes for All Platforms Fix: Prevented IV reuse when repeatedly up