Closed aminelaadhari closed 7 years ago
@aminelaadhari model objects are not serializable using the Java Serializable
interface, because the ValuesStorage
objects they use to hold property values are in turn not serializable. You can however make model objects implement Parcelable
, by using the androidModels
code generation option documented on this wiki page. You can also see an example of declaring this option in our test project. Hope that helps!
Thanks @sbosley but in my current context I can't make objects implement Parcelable. Do you think of another solution?
@aminelaadhari the only other thing I can think of is to use a code generation plugin to alter the generated model's superclass to a custom superclass that implements the serializable interface correctly. We do this for parcelable using classes like AndroidTableModel -- it creates a specialized ContentValuesStorage
object for holding model values that implements parcelable, so that the model's values can be written to and read from parcels. You might be able to do something similar for serializable.
Can I ask why parcelables are unavailable to you? Do you need to serialize objects to disk outside of a SQLite database for some reason?
@aminelaadhari also, if you'd like faster support, you can join our gitter chat. It's generally a better channel for this kind of support than GitHub issues.
Will try your suggestion, thanks!
Hi, When a model class implementing Serializable is deserialized, all the properties are null. Is there any reason why deserialization is not working for generated model classes?
I can't use parcels. Thanks !