Serializable and Parcelable Notes

Serializable:
    serialVersionUID
The same indicates that the serialized class and the current class have the same version and can be deserialized successfully.
Different, indicating that the serialized class has changed compared with the current class, and the deserialization fails.

If the serialVersionUID of the class is the same, but some member variables are added or deleted, the deserialization can still be successful; but if the class name or the type of the class member variable changes, the structure of the class has a destructive change and cannot be recovered at all. .
Static members do not participate in serialization, and member variables marked with the transient keyword do not participate in serialization.


Serializable和Parcelable:
Serializable is a serialization interface in Java, which is simple to use and expensive. IO-based approach.
Parcelable is a serialization method in Android, which is more suitable for Android. It is troublesome to use and has high efficiency. memory-based approach.
Parcelable can also be serialized for storage to the device and transmitted over the network, but it is complicated to use, and Serializable is used in both cases.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325903141&siteId=291194637