Android - 用于持久存储的 Parcel

标签 android serialization

我有兴趣在 Android 应用程序中使用 Parcelable 进行持久存储,该应用程序会将数千个自定义对象(由字符串组成)写入内部存储器(因为它的速度快得多 - this article says 2x fasteranother 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/

相关文章:

android - 显示对话框后如何关闭应用程序?

java - 在 JAVA 中使用 GSON 序列化内部类

asp.net-mvc - 将 KeyValuePair 序列化为 JSON 中的 [Key,Value]

Java反序列化,将字段更改为 transient

java - 与多个 fragment 通信的 Android 服务

android - 选项卡主机中的问题

android - 为什么我的项目未被授权使用 API key ?

c# - Linq to SQL 与序列化

java - 无法使用 Jackson 将对象序列化为 Json

java - 当 Android 中的 GLSurfaceview 中 opengl 上下文丢失时,如何清理 native 堆?