读取非初始化目录下的文件时,真正读取的文件名有问题,这是Android遗留的问题,为什么鸿蒙Next上也有此问题? #1378
-
最近正在做Android数据迁移到鸿蒙,发现读取非初始化目录下的mmkv文件时,指定读取的文件名会变成另外一个字符串。查询后发现是[Android历史bug](MMKV::MMKV(const string &mmapID, int size, MMKVMode mode, string *cryptKey, string *rootPath, size_t expectedCapacity)),为什么会出现在鸿蒙上呢?导致我在鸿蒙上也只能用 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
It has nothing to do with HarmonyOS NEXT. This is a historical bug in the Android platform dating from the very early versions of MMKV. |
Beta Was this translation helpful? Give feedback.
-
但是,实际上并不存在备份这个操作,系统升级切换到Next的时候,系统只会把沙盒文件拷贝到备份恢复目录,然后做迁移。现在的情况是,我们的mmkv文件都在默认目录下,所以文件名都是正确的。但是在迁移时,读取我只能使用 |
Beta Was this translation helpful? Give feedback.
-
并且我看了看代码,这个id错误这个问题,应该是仅限于Android平台,所以鸿蒙Next是否也不应该考虑这个问题? |
Beta Was this translation helpful? Give feedback.
-
对于不考虑迁移,或者很少数据需要迁移的应用,鸿蒙NEXT是一个新机会,摒弃Android当时的bug,如果能兼顾两者就好了。 |
Beta Was this translation helpful? Give feedback.
OK, I will try to explain it again. When you "做迁移" from the "备份恢复目录", you
MMKV.restoreAllFromDirectory("备份恢复目录/xxxx/mmkv")
Understand?