What are some difference between Parcelable and Serializable?

Technology CommunityCategory: AndroidWhat are some difference between Parcelable and Serializable?
VietMX Staff asked 3 years ago

In Android we cannot just pass objects to activities. To do this the objects must either implement Serializable or Parcelable interface.

  • Serializable is a standard Java interface. You can just implement Serializable interface and add override methods. The problem with this approach is that reflection is used and it is a slow process.
  • Parcelable process is much faster than Serializable. One of the reasons for this is that we are being explicit about the serialization process instead of using reflection to infer it. It also stands to reason that the code has been heavily optimized for this purpose.

Also consider:

  • Parcelable is faster than Serializable interface
  • Parcelable interface takes more time to implement compared to Serializable interface
  • Serializable interface is easier to implement
  • Serializable interface creates a lot of temporary objects and causes quite a bit of garbage collection
  • Parcelable array can be passed via Intent