Reputation: 1122
I would like to serialize an object to XML inside Android.
Any libs suggested?
PS: Already tried XStream, but it doesn't serialize enums correctly with Android. The issue is here: Serialization problem with Enums at Android
Upvotes: 4
Views: 24023
Reputation: 179
It's not XML, but you might want to use Google's GSON library to serialize objects. It's what they recommend in the their documentation as an alternative to Serializable:
JSON is concise, human-readable and efficient. Android includes both a streaming API and a tree API to read and write JSON. Use a binding library like GSON to read and write Java objects directly.
Upvotes: 1
Reputation: 268
Have you tried simple http://simple.sourceforge.net/ it is working well for me, correctly handles enums, the jar is quite large though 320k.
Upvotes: 8
Reputation: 46844
Unfortunately I don't think there is a good solution for xml serialization of objects in Android yet. Most of the existing solutions are too heavyweight for use in mobile apps, and depend on things Android doesn't support.
For an overview of XML options, see working with xml in Android.
Upvotes: 3