Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
###Android MMKV getAll()函数功能扩展
####1.背景
最新Android MMKV 函数库 不支持getAll()函数,该函数返回一个文件中所有的KV键值对,并且将值解释为相应正确的类型。在使用MMKV的实践中,由于历史原因,多处SharedPreference 使用getAll()方法导致无法完美替换。
####2.PR提交扩展的功能
本次PR提交扩展MMKV支持getAll()函数,解决类型擦除问题,以达到对 SharedPreference 的完美迁移。
####3.兼容性以及局限
####4.原理
功能实现的核心思想:将值的类型信息随着数据一起持久化,让值数据具有”自我解释能力“。在遍历数据时使用数据的类型信息来还原数据的类型,返回java层。
兼容性的处理方式:新创建文件的元信息文件中将包含一个特殊的标记 TYPE_EXPLAIN,老文件不含有此标记。含有该标的文件读写操作将按照可解释类型的路径处理,不含有该标记的文件读写操作使用原有路径。