SQLite and BLOB

91 views
Skip to first unread message

OrangeCAT TwoCanes LLC

unread,
Oct 16, 2019, 1:36:04 PM10/16/19
to MIT App Inventor Forum
Hi,

I'm using SQLite extension in App Inventor 2.  I'm trying to save an image to a table:

CREATE TABLE Images (
        ImageID               char(30) NOT NULL ,
        ThingID                char(9) NOT NULL ,
        Notes                   text NOT NULL   ,
        Image                   BLOB
);

When I am trying to insert a row, the Image column simply saves the filename of the image.

Screenshot from 2019-10-16 10-34-22.png



I've tried to use these blocks in place of "imgPhoto" as well, no joy.

Screenshot from 2019-10-16 10-30-40.png

I've searched online and YouTube, no help found.  

TIA,

-Kevin

Taifun

unread,
Oct 16, 2019, 1:47:16 PM10/16/19
to mitappinv...@googlegroups.com
you might want to try the Image Base64 Extension by Sivagiri_Visakan to convert the image into a base64 string
Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

OrangeCAT TwoCanes LLC

unread,
Oct 17, 2019, 6:17:13 PM10/17/19
to mitappinv...@googlegroups.com
I spent several hours trying to make this work.  No joy.  I get this error: 

Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference

Using these blocks:

Screenshot from 2019-10-17 15-14-03.png

At this point, the image was taken and saved (global fileName) in /myApp/1001/1001-001 folder.

Taifun

unread,
Oct 17, 2019, 9:15:55 PM10/17/19
to mitappinv...@googlegroups.com
why so complicated blocks?

try is as simple as possible, for example
set global imageString to SImpleBase64.EncodeImage file:///mnt/sdcard/yourDirectory/yourFIle.jpg

and use Do it to debug your blocks, see tip 4 here https://puravidaapps.com/learn.php
make sure, you are using the correct file name including path, for example

full path
file:///mnt/sdcard/yourDirectory/yourFIle.jpg

relative path
/yourDirectory/yourFIle.jpg

Taifun
Reply all
Reply to author
Forward
0 new messages