I don't quite understand the use of Parcelable()
and Serializable()
.
What is the difference between Serializable()
and a Parcelable()
?
In which cases can I use a Parcelable
and in which cases a Serializable
?
I don't quite understand the use of Parcelable()
and Serializable()
.
What is the difference between Serializable()
and a Parcelable()
?
In which cases can I use a Parcelable
and in which cases a Serializable
?
The best thing about
Serializable()
it is that only the interface is needed and Java takes care of doing it to the best of its ability.You will be better off with
Parcelable()
android as it is much faster and more efficient as it is made specifically for Android.I leave you some information that will help you ;) http://www.developerphil.com/parcelable-vs-serializable/
Parcelable , it is much faster than Serializable since it is optimized for use in Android, the interface created by Google is android.os.Parcelable , in terms of implementation it will probably take more time compared to Serializable, but you will get better benefits.
Serializable , is slower compared to Parcelable. It uses the standard java interface, for this reason its implementation is simpler compared to Parcelable. An important feature is that a Parcelable array can be sent via an Android intent. An unfavorable feature may be that Serializable creates a lot of objects in memory, even though they are temporary it can cause a bit of Garbage Collecting .
If you are developing on Android as your question indicates, the option is to use Parcelable
I add a benchmark table where you can compare the speed of both interfaces.
source: Parcelable vs Serializable (English)