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
C++NOASSERTIONCreated 2018-09-17
Download: v2.4.3v2.4.3 ↓2.4.32026-10-16
-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 the

Top issues

Discussions

Latest release

v2.4.3 v2.4.3 2026-10-16
v2.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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON