I have this simple model class here:
public class News implements Parcelable {
private String title;
private String content;
public News(String title, String content) {
this.title = title;
this.content = content;
}
protected News(Parcel in) {
title = in.readString();
content = in.readString();
}
}
Quite simple and works well.
However, what I don't understand is, how does Parcel
know what to read when I say readString()
? Both the title
and content
are just String
s and I call the exact same method. How come Android doesn't mix up the results?
Or do I have to specify an order in which I call the in.readString()
s?
I'd like someone skilled to clear things up for me.