0

The response I got to my previous question : https://stackoverflow.com/questions/15489956/sending-data-structure-through-byte-android states that I should look into serialization for converting my data to a byte array for transfer via bluetooth.

I have been looking into it but can't find any definite answer that states whether I am able to transfer a whole instance of an object, I was originally thinking of sending several arrays but now I am thinking maybe I can just create an object:

"Test" parameters:

Test Name - String

Questions - Array of Strings

Question Answers - Array of Strings

Correct Answers - Array of Ints

My programming isn't that great so I was wondering, could I create this class, let the user on one device construct an object and then pass THAT object itself on through serialization (as shown in Java Serializable Object to Byte Array)

Will this ACTUALLY fully work and give me a whole object on the other system from which I can access the data elements I need?

Sorry if this is a stupid question but as I stated before my programming isn't that great and so I get confused sometimes :(

Thanks!

Community
  • 1
  • 1
aspirant_sensei
  • 1,568
  • 1
  • 16
  • 36

1 Answers1

1

could I create this class, let the user on one device construct an object and then pass THAT object itself on through serialization

Short answer: Yes

But don't forget that class have to implement Serializable interface or NotSerializableException will be thrown.

Will this ACTUALLY fully work and give me a whole object on the other system from which I can access the data elements I need?

Yes but this "other system" must know about this class. So if you create class

public class Foo implements Serializable {

   private String name;
   private int age;

   // getters and setters
}

Application that want to deserialize object, must have this class in build path, simply said.

Simon Dorociak
  • 33,374
  • 10
  • 68
  • 106