I have the following class definition:
public class Message {
private String sender, text;
public Message(String sender, String text) {
this.sender = sender;
this.text = text;
}
}
I would like to be able to send an instance of this Message class over a bluetooth socket. In order to do this, it will need to be converted into a byte[]. After it has been sent, I need to convert it back to a Message object (on the other side of the socket). How can I achieve this?
Two possible answers
Serializable vs Parcelable
Serializable relatively easy to implement but not efficient in term of memory and CPU
http://developer.android.com/reference/java/io/Serializable.html
Parcelable more complex to implement but more efficient in term of memory and CPU
http://developer.android.com/reference/android/os/Parcelable.html