Re: How to write and read a blob object in SQLITE

if you want to use sql i would serialize directly to sql. serializing to json, then storing that in sql makes little sense.

----------------------------------------------------------feel free to press the like button on the right side to thank the user that helped you.please mark posts as solved if you found a solution.@SimonHain on twitter

1) Deserialization is mostly handled by the JSON parser - you don't have to read the bytes directly

2) The data is 'readable' - in that you can extract the blob, stick the string in a JSON parser, and have a good idea of what the data is. Make debugging easier.

3) My experience serializing Objects is that over time, Objects change. The advantage of serializing to a form like JSON, is that then the Application program is isolated from this change. It is easy to deserialize back to a JSONObject and then extract from that JSON Object the information that you need. This is much simpler than creating a byte stream directly where you need to know the order of the primitives you are extracting and then do some fancy processing where you have contained Objects.

I recognize there are issues with doing this, most notably the extra overhead. But I think this is worth it and in places I will do this to Objects I store in Persistent store so that the application doesn't have to worry about changes to the persisted Object.

Re: How to write and read a blob object in SQLITE

serializing to byte stream is not advisable anyhow unless you have to, for example for the OTA-Sync-API.In sql you can create a database field for every attribute you have and serialize the whole object.

basically the thread asks how to do something very specifically, and while that is possible it would be much easier to do it another way, specifically using persistence or by writing all attributes into sql instead of a blob.

----------------------------------------------------------feel free to press the like button on the right side to thank the user that helped you.please mark posts as solved if you found a solution.@SimonHain on twitter

Re: How to write and read a blob object in SQLITE

The flash memory is used for applications, so putting a large object in persistent store reduces the available space the same as loading a similar sized program. If you were just keeping on 0.5MB sized object, then that would be the same as installing a new 0.5MB application. That is why I said:

Would you be concerned about downloading another program that was 1 MB?

But 25 Objects of that size is potentially significant. And the time taken to download and upload that size is significant as well. I would put it on the SD Card, in some form, either convert to SQL row for each image as Simon suggests, or serialize to a byte form and put on SD Card as a file.