What is Parcelable in Android?

Technology CommunityCategory: AndroidWhat is Parcelable in Android?
VietMX Staff asked 4 years ago

Parcelable is the Android implementation of the Java Serializable. It assumes a certain structure and way of processing it. This way a Parcelable can be processed relatively fast, compared to the standard Java serialization. To allow your custom object to be parsed to another component they need to implement the android.os.Parcelable interface.

You can use Parcelable in Activity like:

intent.putExtra("student", new Student("1")); //size which you are storing

And to get this object :

Bundle data = getIntent().getExtras();
Student student = (Student) data.getParcelable("student");

In short use Parcelable to convert an object into a sequence of bytes which can be read/transferred between Activities.