Parcelable vs. Java Serialization in Android App Development

Android developers often face a predicament while passing object references to activities of whether to go with the Java Serialization method or opt for Android Parcelable. This blog is my attempt to compare the two techniques and cite an example to help decide which one of these is the best approach for passing an object from one activity to another.

Passing primitive data types like string, integer, float, etc. through intents is quite easy in Android. All you have to do is put the data with unique key in intents and send it to another activity. If a user wants to send Java objects through intent, Java class should be implemented using the Parcelable interface. Serialization, on the other hand, is a Java interface that allows users to implement the interface which gets marked as Serializable.

During the Android application development process, developers often have to send Java class objects from one activity to another activity using the intent. Developers can opt from the two types of object passing techniques, i.e. Serialization and Parcelable of object.  The fact that Parcelable is faster than Serialization makes it a preferred choice of approach while passing an object. Here’s why:


Android Parcelable implementation allows objects to read and write from Parcels which can contain flattened data inside message containers.

If a developer wants to convert a Java object into Parcelable, then the best way to do so is by implementing the Parcelable interface and overriding the writeToParcel() methods in its own class. The first step is to override the writeToParcel() method and  write all object members into parcel objects. The second is to create a static Parcelable.Creator object to de-serialize the Java object.

Differences between Serialization and Parcelable

Parcelable and Serialization are used for marshaling and unmarshaling Java objects.  Differences between the two are often cited around implementation techniques and performance results. From my experience, I have come to identify the following differences in both the approaches:

·         Parcelable is well documented in the Android SDK; serialization on the other hand is available in Java. It is for this very reason that Android developers prefer Parcelable over the Serialization technique.

·         In Parcelable, developers write custom code for marshaling and unmarshaling so it creates less garbage objects in comparison to Serialization. The performance of Parcelable over Serialization dramatically improves (around two times faster), because of this custom implementation.

·         Serialization is a marker interface, which implies the user cannot marshal the data according to their requirements. In Serialization, a marshaling operation is performed on a Java Virtual Machine (JVM) using the Java reflection API. This helps identify the Java objects member and behavior, but also ends up creating a lot of garbage objects. Due to this, the Serialization process is slow in comparison to Parcelable.

I ran a test and here are my findings:

Intent intent = new Intent(ParcelableActivity.this, RegistrationSuccessActivity.class);
/// for Parcelable list
intent.putParcelableArrayListExtra("data", pacableArray);
/// retrieve in another activity
RegistrationPogo registrationPogo= getIntent().getParcelableExtra("data");
package com.threepillar.bestpractice.ui;
import Java.util.HashMap;
import Java.util.LinkedHashMap;
import Java.util.Map;
import Android.os.Parcel;
import Android.os.Parcelable;
import Android.widget.EditText;
public class RegistrationPogo implements Parcelable {
	String firstName = "", lastName = "", emailAddress = "", phoneNumber = "",
			city = "", state = "";
	int zipCode;
	HashMap<string, String> mapRegData = new HashMap<string, String>();
	public HashMap<string, String> getMapRegData() {
		return mapRegData;
	public void setMapRegData(HashMap<string, String> mapRegData) {
		this.mapRegData = mapRegData;
	public String getFirstName() {
		return firstName;
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	public String getLastName() {
		return lastName;
	public void setLastName(String lastName) {
		this.lastName = lastName;
	public String getEmailAddress() {
		return emailAddress;
	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	public String getPhoneNumber() {
		return phoneNumber;
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	public String getCity() {
		return city;
	public void setCity(String city) { = city;
	public String getState() {
		return state;
	public void setState(String state) {
		this.state = state;
	public int getZipCode() {
		return zipCode;
	public void setZipCode(int zipCode) {
		this.zipCode = zipCode;
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	public RegistrationPogo() {
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		final int N = mapRegData.size();
		// dest.writeInt(N);
		if (N > 0) {
			for (Map.Entry<string, String> entry : mapRegData.entrySet()) {
				String dat = entry.getValue();
	public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
		public RegistrationPogo createFromParcel(Parcel in) {
			return new RegistrationPogo(in);
		public RegistrationPogo[] newArray(int size) {
			return new RegistrationPogo[size];
	private RegistrationPogo(Parcel in) {
		firstName = in.readString();
		lastName = in.readString();
		emailAddress = in.readString();
		phoneNumber = in.readString();
		city = in.readString();
		state = in.readString();
		zipCode = in.readInt();
		final int N = in.readInt();
		for (int i = 0; i < N; i++) {
			String key = in.readString();
			String value = in.readString();
			mapRegData.put(key, value);

Speed Testing Results

In this example, Android Parcelable came out to be faster than the Java Serialization technique. One of the main reasons was the fact that Parcelable is fully customizable, allowing developers to convert required data into Parcelable. Serialization is a marker interface as it converts an object into a stream using the Java reflection API. Due to this it ends up creating a number of garbage objects during the stream conversation process. So my final verdict will be in favor of Android Parcelable over the Serialization approach. I have tested both performances on HTC Desire, Nexus 4 and Samsung Galaxy S3 and my findings can be viewed in the graphical representation that follows. The scale on the y-axis is the number of milliseconds it took Parcelable and Serialization to return results based on the API calls above.

Speed Testing Results
Ravindra Kumar Prajapati

Ravindra Kumar Prajapati

Senior Software Engineer

Ravindra Kumar Prajapati is a Senior Software Engineer at 3Pillar Global. He has worked on many Android mobile application development projects in the company, including projects like WorldCal (meeting scheduler) and Vriti (e-learning app). Prior to joining 3Pillar, Ravindra has worked with Ascent Software Services as a mobile application developer. He has gained extensive knowledge in mobile applications on Android, Blackberry and J2ME mobile operating systems.

35 Responses to “Parcelable vs. Java Serialization in Android App Development”
  1. Rajeef on

    Thanks for the review. I was actually finding it tough make the choice.

  2. sparsh jain on

    lucid explanation. Thanks , God bless you

  3. Eric on

    How did you implemented the testing. Could you give some code example ?

  4. Dheeraj Kumar on

    Great Explanations.Thank you.

  5. Manish Bansal on

    Nice Explaination.. Good job Ravinder

  6. Mashhood on

    Excellent explanation thanks!

  7. mark on

    Thanks for a great explanation

  8. Annada on

    Thank you for a detailed and comparison analysis. Really helpful.

  9. Abhit Nigam on

    Thanks Ravinder for such a good blog, I m hoping for more in future.

  10. Abhishek on

    Excellence Explaination

  11. Neha on

    Quite helpful

  12. Parth Vora on

    Wow this blog helped me a lot for understanding the difference between Parcelable and Serializable.

  13. Sudheesh B on

    Nice explanation and very useful.

  14. Monish Kamble on

    Well explained. Very simple to understand.
    Thank You Ravindra.

  15. Sonia Rana on

    Thank you so much,This is the explantion for which i was looking.

  16. saurav on

    Very nice Explanation….

  17. Bharatesh on

    thanks a lot Sir.

  18. Shamili on

    Very Detailed Explanation… Clarified many doubts… Thank You.

  19. Mritunjay Pratap Singh on

    This is understanding and simple answer.This type of answer realy help to people

  20. Kush on

    Very detailed explanation!
    Many thanks…

  21. Pavel Lahoda on

    Have you considered the option of passing the original object (without both Serialization and Parcel mechanism) ? When you talk about “passing object references” from the performance perspective, this is definitely the fastest option available.
    While you can’t pass such an object directly as a data of the intent it is relatively easy to specify the location where the recipient can obtain the original object since it still runs inside of the single VM (if it is ment to be used by intent handled by another application, Serialization might be quite problematic anyway).

  22. Jagdish on

    Very helpful explanation example, thanks for that

  23. Ankit on

    Very Helpful

  24. Savan Kashiyani on

    Very neat and clean explanation,
    Thanks a lot for your efforts.

  25. Matthew Dolan on

    Serializable by default uses reflection, however it is possible, as per the documentation ( to implement writeObject and readObject methods in a similar way to Parcelable. Doing this will typically make Serializable faster than Parcelable.

    It’s also worth noting that an advantage of Serializable is the possibility to write a pure Java unit test on its serialisation which you cannot do so easily with Parcelable because of its dependency on the Android SDK.

  26. Anjali on

    You have written a very nice article. Keep it up! I will follow up your for future post. Thanks for sharing.
    Cloud you explain the difference between Array and ArrayList?

  27. Owais Idris on

    Thanks for this article. I have been using Serializable all this year. Apart from performance on can also compare efforts in writing parcelable and Marking Serializable. Here Serializable wins as it is very easy to implement. Hence developer must decide and device their models when to be parcelable and when to uses Serializable.

  28. subha on

    Clear Explanation. thank you very much bro.

  29. Vijay makwana on

    Really nice explanation, I understand why parcelable not ignorable in Android development over serialization

  30. Sushant on

    Thankyou, That is the easiest and best explanation I can find.

  31. $neh@ on

    Good explanation. Thanks : )

  32. pankaj kumar singh on

    Really a valuable explanation and Sir you have touch every point. Thank you so much.

  33. john parker on

    The differences between parcelable and serialization are due to well-documented features in Android APK, developers prefer parcelable than serialization. The parcelable uses less java garbage object than serialization.

  34. Jai Bhati on

    Thank you sir for the review. Very helpful!

  35. Kalyani on

    Nice article.easy to understand

Leave a Reply