保存parcelable类到文件 [英] Save parcelable class into file
问题描述
我使用的是序列化的类我保存XML解析器的结果,但是当我看到,这是很慢的Android,我改parcelable类。
I was using a serializable class for I save the xml parser result, but when I read that It is very slow in Android, I changed to parcelable class.
现在,我想的内容parcelable类保存到文件中。
Now, I want to save the content parcelable class into file.
我该怎么办呢?
感谢。问候。
推荐答案
包裹的是不是一个通用的序列化机制。这个类 (和相应的API Parcelable放置任意对象 成包)被设计成一个高性能的IPC传输。如 这样,这是不恰当放置任何包裹数据在持久性 存储:变化中的任何数据的底层实现 在包裹可以使较旧的数据无法读取。
Parcel is not a general-purpose serialization mechanism. 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.
Parcelable
是为 IPC
只使用,不用于被持久化。所以,你必须将你的对象转换成某种持久化数据结构,如 XML
, JSON
,序列化
。
Parcelable
is meant for IPC
use only and is not designed to be persisted. So you have to convert your object into some sort of persistable data structures like XML
, JSON
, Serializable
.
这篇关于保存parcelable类到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!