A
A
Alexander Vasilenko2016-08-09 07:10:57
Android
Alexander Vasilenko, 2016-08-09 07:10:57

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

3 answer(s)
A
Artem Gapchenko, 2016-08-09
@SanchelliosProg

Actually the goal is only to protect the code from unnecessary dirt.

Specify where "extra dirt" occurs.
It seems that a new field was added, but they forgot to specify it in writeToParcel()and ? createFromParcel()Well, that's it, AutoValue + AutoParcel , and there is no such problem anymore.
To save - yes. To transfer an object from one Activityto another - no. But I can imagine cases where some sort of non- Parcelableserialization would be necessary . For example, your class object contains Bitmap, or just a byte array. When you try to put this object into Bundlean Parcelableexception, 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 Bitmapto the card as a file, and forward the path to the file to the next Activity.

O
Oleg Gamega, 2016-08-09
@gadfi

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 question

Ask a Question

731 491 924 answers to any question