-
-
Notifications
You must be signed in to change notification settings - Fork 2k
FAQ
-
When should I use MMKV?
If those scenarios are seen familiar to you, you should choose MMKV:- Your iOS/Android App needs generic key-value storage;
- You worry about writing efficiency;
- Inter-process access causing your Android App ANR.
-
Is Swift supported?
Yes, MMKV is Swift compatible. For detail usage, see demo. -
Is Kotlin supported?
Yes. The Android API works in Java and Kotlin; see the Android Kotlin demo. Starting from v2.4.1, MMKV also provides experimental Kotlin Multiplatform support for shared Android and iOS code. -
What kind of encryption algorithm does MMKV use?
MMKV uses AES CFB-128/256 for encryption and decryption, using OpenSSL's implementation (version 1.1.0i). We choose CFB instead of widely used CBC, mainly because MMKV implements insert/update by an append-only operation. Stream encryption algorithms like CFB are more suitable. -
What're MMKV's limitations?
MMKV works well in most cases. Starting from v2.4.1, an encoded key can be at most 65,531 bytes; oversized keys are rejected. Values are constrained by available memory and any configureditemSizeLimit. Since MMKV caches everything in memory, an App may receive a memory warning when the total size is too large (such as 100M+), and writes may slow down when a full write-back is needed. -
What is MMKV's usage of FD(file descriptor)?
MMKV is backed by a file that is mmapped into memory. MMKV also relies on a metafile to keep track of the CRC32 checksum, store the encryption IV, and coordinate interprocess operations. Each MMKV instance therefore uses two FDs. If necessary, you canclose()an instance after ensuring no operation is running.close()permanently destroys the native instance and invalidates every reference backed by it; discard all references before reopening the same ID. -
How do I backup MMKV's data (and restore/move to another device)?
As it's been described above, MMKV is backed by one data file and one metafile. So you have to back up the MMKV data file itself, plus the*.crcmetafile. -
Does MMKV for iOS support multi-process accessing?
Yes, MMKV for iOS adds multi-process support in v1.1.0. -
What is Ashmem MMKV in Android, and when should I use it?
Ashmem MMKV in Android is a memory-only, inter-process sharing key-value storage. It vanishes when all processes of the App exit. It doesn't use any file as backing storage. Thus it's suitable for sharing sensitive information among processes of the same App. -
I'm having
java.lang.UnsatisfiedLinkErroron Android devices with API level 19. What is that, and what should I do?
Some Android devices with API level 19 might have problems when installing/updating APK, aka missing libmmkv.so. There's an open-source project ReLinker that fixes this problem. You can use it to load MMKV by callingMMKV.initialize(String rootDir, LibLoader loader). Example code can be found in mmkvdemo. -
Can I redirect/turn off MMKV's logging?
Yes. There's an API added to turn off logging & redirect logging in v1.0.17. -
Why is my MMKV instance not syncing data cross multi-process?
It's highly possible that you forget to pass multi-process mode. Note that once an MMKV instance is accessed by multi-process, anywhere else that uses that instance must set the multi-process mode as well.
The simplest way to diagnose this is to set the multi-process mode to everywhere that access this MMKV instance. Check if it happens or not. -
Why does my MMKV instance lost data after App restart?
There are some possibilities:- You forget to set the multi-process mode to open a multi-process MMKV instance. Try setting multi-process mode to everywhere that access this MMKV instance. Check if it happens or not.
- The file is corrupted. It happens when there's a sudden shutdown of the device. The OS fails to sync data from mmap memory to the file. You can set a recovery strategy, or call
sync()manually when you see fit. - There's some unknown bug in MMKV. Create an issue after you have tried the above methods and failed.
-
Why does MMKV crash on my App?
There are some possibilities:- You forget to set the multi-process mode to open a multi-process MMKV instance. Try setting multi-process mode to everywhere that access this MMKV instance. Check if it happens or not.
- There's some unknown bug in MMKV. Create an issue after you have tried the above method and failed.
MMKV is published under the BSD 3-Clause license. For details check out the LICENSE.TXT.
Check out the CHANGELOG.md for details of change history.
If you are interested in contributing, check out the CONTRIBUTING.md, also join our Tencent OpenSource Plan.
To give clarity of what is expected of our members, MMKV has adopted the code of conduct defined by the Contributor Covenant, which is widely used. And we think it articulates our values well. For more, check out the Code of Conduct.
Check out the FAQ first. Should there be any questions, don't hesitate to create issues.
User privacy is taken very seriously: MMKV does not obtain, collect or upload any personal information. Please refer to the MMKV SDK Personal Information Protection Rules for details.
- In English
- 中文
- In English
- 中文
- In English
- 中文
-
In English
-
中文
-
Golang
- In English
- 中文