Android Question Serializing data to send to PC

Arf

Well-Known Member
Licensed User
Longtime User
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?

Any suggestions gratefully received!
 

Arf

Well-Known Member
Licensed User
Longtime User
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?
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
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.
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
In my case...

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).
 
Reactions: Arf
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
B4J will be easier, but for portability, Serialize the data with the JSON Lib, and then compress it with CompressedStreams.

C# can decompress and understand JSON
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
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.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…