I always do this.. work hard to get all my data out of a SQL DDB into a nice big tidy structure and think it'll be easy to transmit up to a PC, then realise I can't do that. Usually I work with C++ and pointers and then it's simple.
So now I've got all my data in a big Type filled with lots of other custom Types and I'm stuck.
I need to transmit that package of data to a PC and a C# application will receive and unpack it. Any suggestions as to how I can look to do so without writing a massive function to serialize all the data?
I thought maybe one way would be to extract the data into a smaller temporary SQL DDB and send the file up. We use SQLLite on the PC side so I don't know if this will be able to deal with the received file?
I saw a post from the desolate soul, where he uses RAF to write objects to a file.
I guess even if I can serialise obects using RAF or whatever, the problem is going to be that when the data is received on the PC side the data type is going to be alien.
Or is there is there perhaps some kind of datatype which i wil be able to deal with easily on the receiving end?
Have you considered JSON? Create methods that convert each custom type into a JSON String (you will probably create an intermediary Map in the process). Nested Types will create perfectly legal nested JSON Strings. On the PC side, use C#'s JSON parser to unpack the whole thing.
I usually create an encapsulating class for each database table I need to interact with, and if I need to export/import information I create a .ToXML/.FromXML method that returns/accepts an XML string containing the information (XmlSax library on the B4X side, and System.Xml.XPath on the .NET side).
The simplest solution is to implement the PC side with B4J. You can then use B4XSerialiaztor to convert the object to bytes and then back to an object.
Thanks all, I wrote a serialisation function in the end, seems to work just fine so will stick with that.
For future reference - is it possible to write PC-side code in B4J that can be included into a C# project as a library or something like that?
I've not worked with B4J much yet.