我有兴趣在 Android 应用程序中使用 Parcelable 进行持久存储,该应用程序会将数千个自定义对象(由字符串组成)写入内部存储器(因为它的速度快得多 - this article says 2x faster 或 another article says says 10x faster )。
"This class (and the corresponding Parcelable API for placing arbitrary objects into a Parcel) is designed as a high-performance IPC transport. As such, it is not appropriate to place any Parcel data in to persistent storage: changes in the underlying implementation of any of the data in the Parcel can render older data unreadable."
https://developer.android.com/reference/android/os/Parcel.html
"changes in the underlying implementation of any of the data in the Parcel can render older data unreadable"
特别是这一行,有人能详细解释一下这意味着什么吗?
文档是否说“字符串”级别的某些内容的实现发生了变化,或者更确切地说是在我正在打包的自定义类之一中?
如果我要坚持使用一种实现(又名存储数千个由 4 个字符串组成的对象),那么可分割的似乎是读取数千/数万个对象的速度的方法
最佳答案
Are the docs saying that the implementation of something at the level of "String" changes or rather in one of the custom classes that I am parcelling?
可能会发生以下变化:
- 您的自定义类之一
- 恰好是
Parcelable
的框架类之一,您选择将其包含在Parcelable
中(例如,Bundle
、Intent
,或 ~300 others 中的任何一个)
If I am going to be sticking with one implementation
你无法预测 future 。您的数据模型可能需要更改。
it seems parcelable is the way to go for speed of reading thousands/tens of thousands of objects
没有。
关于Android - 用于持久存储的 Parcel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41079026/