01-24-2014 04:30 AM
01-24-2014 05:13 AM
"serializing to json, then storing that in sql makes little sense".
There are three advantages I see:
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.
01-24-2014 05:54 AM
01-24-2014 06:11 AM
"it would be much easier to do it another way, specifically using persistence or by writing all attributes into sql instead of a blob."
Very good point, I have been blinkered by the question and focused on creating a blob rather than storing an Object. My bad. Thanks Simon.
OP, please review Simon's comments carefully.
01-25-2014 02:51 AM
CreateBlobOutputStream is not supported on 6.o API
d.createBlobOutputStream( "MyTable1", "MessageBody", d.lastInsertedRowID( ) );
is not supported.
Is there any max limit of the storage in persistant storage?
While saving 400 or 500 Kb Object in device Memory as a persistant Object,if device such as 9650 has flash memory less than 1 GB,Will there any issue in saving DB .
I am not fully aware of flashmemory .Is there any thing to do while saving as persistant Object.
01-27-2014 04:29 AM
"saving 400 or 500 Kb Object in device Memory"
If you only have one of these, then I don't think there would be too much concern. Would you be concerned about downloading another program that was 1 MB?
"Is there any thing to do while saving as persistant Object."
Try this tutorial:
01-27-2014 04:51 AM
I will be savingnearly 20 - 25 Objects of max size around 500 - 700 Kb .
" Would you be concerned about downloading another program that was 1 MB?"--->I did nt understand.
I will be saving as Object if connectivity is down temporarily and upload it back to server,if connectivity is up.
01-27-2014 05:19 AM
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.