Skip to content
Related Articles
Open in App
Not now

Related Articles

Difference Between Serializable and Parcelable in Android

Improve Article
Save Article
Like Article
  • Last Updated : 27 Feb, 2023
Improve Article
Save Article
Like Article

Android is a mobile operating system developed by Google and it is used by millions of people all over the world. Android is open-source software and is widely popular for its user-friendly interface and flexibility. The Android platform supports two different ways of transferring data between activities, namely serializable and parcelable. Both of these methods are used to store and transfer data across activities, but they have some notable differences.

What is Serializable in Android?

Serializable is a Java interface that enables an object to be serialized, meaning that it can be converted into a byte stream and stored in a file or transmitted over a network. This is a simple method of saving objects to a file or sending them over a network. When an object is serialized, it is converted into a byte stream that is easily readable by the receiving end. The receiving end can then convert the byte stream back into an object. Serialization is a quick and efficient way of transferring data across activities.

What is Parcelable in Android?

Parcelable is an Android-specific interface that enables an object to be passed as a parameter from one activity to another. This is a more efficient method compared to serialization, as it doesn’t require the object to be converted into a byte stream. When an object is passed using parcelable, it is passed directly from one activity to another. Parcelable also has the advantage of being able to pass a large amount of data in a single call, making it more efficient than serialization.

Difference Table

Factor

Serializable 

Parcelable

OverviewSerializable is the standard Java interface for persistence.Parcelable is the Android-specific interface for persistence. 
SerializationObjects are serialized using the Java Serialization API.Objects are serialized using the Android Parcelable API.
Memory UsageSerializable objects are stored in memory and can be retrieved quickly.Parcelable objects are stored in an Android application bundle and require more time to access.
SpeedSerializable is slower than Parcelable.Parcelable is faster than Serializable.
SizeSerializable objects are larger than Parcelable objects.Parcelable objects are smaller than Serializable objects.
ImplementationSerializable objects are implemented by implementing the Serializable interface.Parcelable objects are implemented by extending the Parcelable class.
HierarchySerializable supports class hierarchy.Parcelable does not support class hierarchy.
ReflectionSerializable objects can be accessed using Java’s reflection API.Parcelable objects cannot be accessed using Java’s reflection API.
Thread SafetySerializable objects are not thread-safeParcelable objects are thread-safe
My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!