Interface for classes whose instances can be written to and restored from a Parcel.
Classes implementing the Parcelable interface must also have a non-null static field called CREATOR of a type that implements the Parcelable.Creator interface.
There are two options to realize serialization:
Serializable Interface
Parcelable Interface (Android Only)
Here parcelable is more efficient. It could be used to transfer object by intents and IPC (inter-process communication). In general, we could only use intents to pass values like int, string and so on. But now with Parcelable, you can transfer Objects like a car, a person :P
PS: Both of these two interfaces could achieve this. Bundle.putSerializable(Key, Object) for Serializable interface. Bundle.putParcelable(Key,Object) for Parcelable interface.
How to choose between them?
Parcelable is more frequent in the use of memory.
Serializable will produce a large number of temporary variables which causes freqiemt GC.
Parcelable is not appropriate to place any Parcel data in to persistent storage. Changes in the underlying implementation of any of the data in the Parcel can render older data unreadable. In this situation, Serializable could be better.
Why serialization?
1) To permanently save the object, by sequence of bytes saved to a local file.
2) To pass an object in the network. 3) To pass an object between processes (IPC).
When to use it?
If you need to transfer complex data types (objects) between components like Activity or Service. For simple data like int, just use Intent directly.