On Wednesday, April 3, 2019 at 2:54:04 AM UTC+2, Thomas wrote:
> I need to store some byte encoded serialized objects (like protobuf 
> encoded objects and similar) into an SQLite table. But I have seen in the 
> forum that there was some issues with the support of BLOB type in SQLite by 
> CN1. However, these posts are quite old and since then, some plugins like 
> https://github.com/shannah/cn1-spatialite have appeared that seems to 
> work with BLOB type with no issue (spatilite encode each Geography object 
> as a wkb BLOB object in the SQLite database and, as this plugin is working 
> with both Android and iOS, I assume the support of BLOB type on iOS is no 
> longer problematic, exept if this plugin is shipping with its own SQLite 
> engine...). 
> So can I use BLOB type in SQLite with CN1 without issue now (I am 
> targeting Android and iOS only) or is it still problematic? If so, how can 
> I write and read a byte array into an SQLite table (do I just have to pass 
> the object as a byte[] object for it to be writen into my BLOB table column 
> ?)
> If the support of BLOB type is still problematic, the alternative would be 
> to encode my bytes buffer objects as String before storing them into the 
> database (with base64 encoding or someting similar) but I would really 
> avoid the unecessary bytes<->String encoding/decoding and storage overhead 
> if I can... 

After looking at the code of the DatabaseImpl from iOS it seems like BLOB 
won't work on iOS as arguments are all converted to String before beeing 
passed to the native interface. Indeed the code of the execute() function 
in this class is:

    public void execute(String sql, Object... params) throws IOException{
        // temporary workaround, this will probably fail with blobs
        String[] val = new String[params.length];
        for(int iter = 0 ; iter < val.length ; iter++) {
            if(params[iter] == null) {
                val[iter] = null;
            } else {
                val[iter] = "" + params[iter];
        execute(sql, val);

So it seems like it is still using a "temporary" workaround that is 
incompatible with byte[] arguments for BLOB data. Kind of sucks that this 
workaround as not been fixed by the time...

You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to