Answer the question
In order to leave comments, you need to log in
How "kosher" is it to store objects in the database using an ORM instead of implementing the Parcelable interface?
Actually, the goal is only to protect the code from unnecessary dirt, which is annoying and from unpleasant errors that can occur when using Parcelable. Do you use an ORM to persist objects?
Answer the question
In order to leave comments, you need to log in
Actually the goal is only to protect the code from unnecessary dirt.
writeToParcel()
and ? createFromParcel()
Well, that's it, AutoValue + AutoParcel , and there is no such problem anymore.Activity
to another - no. But I can imagine cases where some sort of non- Parcelable
serialization would be necessary . For example, your class object contains Bitmap
, or just a byte array. When you try to put this object into Bundle
an Parcelable
exception, you will get an exception (I can lie, but I seem to have fallen on Bitmap
-s weighing about 1.5-2 megabytes). A possible way out is to save this one Bitmap
to the card as a file, and forward the path to the file to the next Activity
.
Parcelable and database are a bit different, as Artem Gapchenko rightly said with Parcelable there are no problems, it is not necessary to write them by hand, there are libraries, there are plug-ins ...
It is quite normal if your model implements Parcelable for transfer between Activities
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question