Serializable and Parcelable in Android -


i not clear distinct use of interface serializable , parcelable in android. if prefer use of parcelable, why on serializable. moreover, if pass data through webservice, can parcelable help? if so, how?

so main difference speed, , matters on hand-held device. supposedly less powerful desktop.

with serialisable comes goold old java, code this:

class mypojo implements serializable {     string name;     int age; } 

no methods needed reflection used fields , values. , can me slow or slower ...

and use parcelable have write this:

class mypojo implements parcelable {     string name;     int age;      mypojo(parcel in) {         name = in.readstring();         age = in.readint();     }      void writetoparcel(parcel dest, int flags) {         dest.writestring(name);         dest.writeint(age);     }      int describecontents() {         return 0;     }      // , here goes creator , not }; 

according guys @google can much faster, parcelables is.

of course, there tools adding necessary fields make class parcelable https://github.com/johncarl81/parceler


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -