Skip to content

Instantly share code, notes, and snippets.

@smyykb
Last active July 25, 2022 08:21
Show Gist options
  • Save smyykb/676d7b38fd0cac7923edcaf691de927d to your computer and use it in GitHub Desktop.
Save smyykb/676d7b38fd0cac7923edcaf691de927d to your computer and use it in GitHub Desktop.
Serializable vs Parcelable
In Android, if we want to pass the objects to activities then there is a need to implement the Serializable or Parcelable interface.
Serializable and Parcelable are two interfaces:
* Serializable is a standard java interface that implemented by “java.io.Serializable”
* Parcelable is an Android-specific interface that implemented by “android.os.Parcelable”
Serializable interface is easy to implement by overriding the methods but it is a slow process
and it creates a lot of temporary objects and causes quite a bit of garbage collection.
Parcelable interface takes more time to implement in comparison to Serializable because of the code size.
But it performs faster than Serializable and use fewer resources.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment