Tencent / MMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Other
17.1k stars 1.88k forks source link

Android平台下生成的mmkv文件,在鸿蒙系统下是否可以读取出来,因为后面Android可以升级到鸿蒙需要做数据迁移 #1315

Closed xinle closed 1 month ago

xinle commented 1 month ago

Android平台下生成的mmkv文件,在鸿蒙系统下是否可以读取出来,因为后面Android可以升级到鸿蒙需要做数据迁移, 目前试了下是不行的,这个是否未来有计划支持?

lingol commented 1 month ago

What is the problem? Please provide logs.

xinle commented 1 month ago

你好这里说的鸿蒙是纯血鸿蒙

xinle commented 1 month ago

I prepare to load /data/storage/el2/base/haps/MainApp/files/mmkv/mDefault_ting_data2_backup (id /data/storage/el2/base/haps/MainApp/files/mmkv/mDefault_ting_data2_backup) from rootPath 29246416848 I open fd[0x73], /data/storage/el2/base/haps/MainApp/files/mmkv/specialCharacter/d40df772a289f7a0eafc907d1a177ea6 I mmap to address [0x5aef3d000], oldPtr [0], [/data/storage/el2/base/haps/MainApp/files/mmkv/specialCharacter/d40df772a289f7a0eafc907d1a177ea6] I RSProfiler::OnRenderBegin(): disabled I open fd[0x74], /data/storage/el2/base/haps/MainApp/files/mmkv/specialCharacter/d40df772a289f7a0eafc907d1a177ea6.crc I mmap to address [0x5aef3e000], oldPtr [0], [/data/storage/el2/base/haps/MainApp/files/mmkv/specialCharacter/d40df772a289f7a0eafc907d1a177ea6.crc] I meta file [/data/storage/el2/base/haps/MainApp/files/mmkv/mDefault_ting_data2_backup] has flag [0] I loading [/data/storage/el2/base/haps/MainApp/files/mmkv/mDefault_ting_data2_backup] with 0 actual size, file size 4096, InterProcess 1, meta info version:4 I loaded [/data/storage/el2/base/haps/MainApp/files/mmkv/mDefault_ting_data2_backup] with 0 key-values

lingol commented 1 month ago

There's nothing wrong with the logs. Which one goes wrong, the _mDefault_ting_data2backup, or the specialCharacter/d40df772a289f7a0eafc907d1a177ea6 ? You should upload the files you extracted from Android for further investigation. One more thing, you have tried to create one mmkv with special characters, you should provide the name of it as well.

lingol commented 1 month ago

Oh, I may have found out what went wrong. Did you try to load it with an absolute path? You should not do that. You should init mmkv with rootPath to /data/storage/el2/base/haps/MainApp/files/mmkv, and load it with the same ID mDefault_ting_data2_backup.

Never pass the absolute path as a mmkv ID.