The difference between Android Parcelable and Serializable, androidparcelable

Updated on technology 2024-05-13
2 answers
  1. Anonymous users2024-02-10

    1. Function. The purpose of Serializable is to save the properties of objects to local files, databases, network streams, and RMIs to facilitate data transfer, which can be within a program or between two programs.

    Android's Parcelable is designed to efficiently transfer data between different components within the program and between different Android programs (AITL) because Serializable is too slow, and these data only exist in memory, and Parcelable is a carrier of messages communicated through iBinder.

    2. Efficiency and choice.

    The performance of Parcelable is better than Serializable, and the memory overhead is smaller, so it is recommended to use Parcelable when transferring data between memories, such as transferring data between activities, and Serializable can persist data for easy storage, so choose Serializable when you need to save or transfer data over the network, because different versions of Android Parcelable may be different, Therefore, it is not recommended to use parcelable for data persistence.

    3. Programming implementation.

    For Serializable, the class only needs to implement the Serializable interface and provide a serialized version ID (SerialVersionUID). Whereas.

    Parcelable needs to implement the writetoparcel, describecontents functions, and static creator variables, which are essentially how to pack and unpack the work yourself, and serialization is entirely implemented by the underlying level.

    4. Advanced functions.

    Serializable does not save static variables, you can use the transient keyword to not serialize some fields, or you can override the writeObject and readObject methods to customize the serialization process.

  2. Anonymous users2024-02-09

    Both are used to support serialization and deserialization operations, the biggest difference between the two is the difference in storage media, Serializable uses io to read and write and store on the hard disk, while parcelable is directly read and written in memory, it is obvious that the read and write speed of memory is usually greater than io read and write, so parcelable is usually preferred in Android.

Related questions
5 answers2024-05-13

More related to your own interests, if you like the elegance of the iPhone, or learn the iPhone. >>>More

4 answers2024-05-13

Maybe many people's tutorials have said that they need SDK+Eclipse, as well as Eclipse plug-ins. >>>More

8 answers2024-05-13

Android is a Linux-based open-source operating system that is primarily used in portable devices. At present, there is no unified Chinese name, and more people in Chinese mainland use Android (unofficial) or Anzhi (official). The Android operating system was originally developed by Andy Rubin and initially mainly supported mobile phones. >>>More

15 answers2024-05-13

Have you ever played 300+ and there are only about 1100 numbers (that is, how to get MVP will not increase the score and play the special number for children with friends), I can take about 1300 and you can also take you to play Dota, I have a ladder of 2100+, you think about it yourself.