Serializable vs Parcelable

In Android we know that we cannot just pass objects to activities. The objects must be either implements Serializable or Parcelable interface to do this.

Serializable

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. This method create a lot of temporary objects and cause quite a bit of garbage collection. Serializable interface is easier to implement.

Look at the example below (Serializable)

 

Parcelable

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.

Look at the example below (Parcelable)

 

Conclusion.

  1. Parcelable is faster than serializable interface
  2. Parcelable interface takes more time for implemetation compared to serializable interface
  3. serializable interface is easier to implement
  4. serializable interface create a lot of temporary objects and cause quite a bit of garbage collection
  5. Parcelable array can be pass via Intent in android

— taken from sof