Save parcelable class into file

浪尽此生 提交于 2019-12-19 10:18:22

问题


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.

Now, I want to save the content parcelable class into file.

How can I do it?

Thanks. Regards.


回答1:


According to Parcel API reference

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 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.



来源:https://stackoverflow.com/questions/15448623/save-parcelable-class-into-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!