0

I'm a new comer to Android development and I happen to stumble upon these words:

  • Serializable objects
  • Serialization
  • Parcelables

Please, what do these words mean and what are they used for?

OneCricketeer
  • 126,858
  • 14
  • 92
  • 185
Faraday
  • 147
  • 4
  • 18
  • 7
    Possible duplicate of [Android: Difference between Parcelable and Serializable?](http://stackoverflow.com/questions/3323074/android-difference-between-parcelable-and-serializable) or [Android Parcelable and Serializable](http://stackoverflow.com/questions/9323044/android-parcelable-and-serializable) read more [**HERE**](http://www.developerphil.com/parcelable-vs-serializable/) – Jordi Castilla Apr 05 '16 at 10:48

2 Answers2

1

Parcelable and Serialization are used for marshaling and unmarshaling Java objects.

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.

Check below link: very good explanation and example.
http://www.3pillarglobal.com/insights/parcelable-vs-java-serialization-in-android-app-development

Govinda Paliwal
  • 2,821
  • 5
  • 18
  • 42
1

from https://en.wikipedia.org/wiki/Serialization

In computer science, in the context of data storage, serialization is the process of translating data structures or object state into a format that can be stored (for example, in a file or memory buffer, or transmitted across a network connection link) and reconstructed later in the same or another computer environment.

There are different ways to make a java-class serializable. Among these are

  • Parcelable is a non-portable android specific format. (non portable: cannot be used outside android)
  • Serializable is the portable java standard binary format that work with all java systems, including android. (binary = for humans unreadable)
  • xml-serialization-in-java is a human readable format.
Community
  • 1
  • 1
k3b
  • 13,724
  • 6
  • 47
  • 81