Save and retrieve Picture from camara (sQlite)

Hello all. I am trying to save and retrieve a picture taken with the phones camara .
I am using an sqlite(Taifun) database.

I am not getting any Errors. But there does not seem to be an image in the database.
I have done a search on the forum. There is some information about mySql and a few other things.
I ask here because that is what Taifin recommends on this site.( App Inventor Extensions: SQlite | Pura Vida Apps

Here is my code blocks.

Thanks for any help with getting this working.

Hello user,

You are not using App Inventor, but another distribution. Please ask on their forum, and the extension developer can help you there.

Also, where did you get the extension "SQLite Addons"? It does not seems to follow the naming conventions. Do you have a link to the topic where you got it?

It is an Andres Cotes extension (can be found in Taifun's list). Naming conventions ignored to match SQL query syntax.

1 Like

What you are doing currently is to store the path to the image, but not the image itself... to store only the path to the image is sufficient and you can display the image later again as long as you do not delete it from the device

However later you send a query to the database to get all images back, which have been stored and try to display all these images at the same time in an image component This obviously will not work. You only can display 1 image.

use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools
Taifun


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

Thanks for your comments. I do not understand how this block code is just storeing the path.

I thought when you insert a picture in a blob field of a sqlite database it stored the image .

Is there some tutorial i can read to help me understand how this blck code works.

I use pascal to retrieve the image from the blob field like this.

procedure TAccessCameraAppForm.SpeedButton2Click(Sender: TObject);
var
        BlobStream: TStream;
  begin
    AccessCameraAppForm.viewimgquery.ParamByName('_PicId').AsInteger :=
    AccessCameraAppForm.FDQuery1.FieldByName('ID').AsInteger;
    AccessCameraAppForm.viewimgquery.Open;
    AccessCameraAppForm.viewimgquery.First;
    while (not AccessCameraAppForm.viewimgquery.EOF) do
        begin
        // access a stream from a blob like this
          BlobStream := AccessCameraAppForm.viewimgquery.CreateBlobStream
          (AccessCameraAppForm.viewimgquery.FieldByName('pictures'),
          TBlobStreamMode.bmRead);
             try
           AccessCameraAppForm.imgCameraImage.Bitmap.LoadFromStream
              (BlobStream);
           // itm := Form4.ListView1.items.Add();
           finally
           BlobStream.Free;
           end;

                AccessCameraAppForm.viewimgquery.Next;
        end;
    end;

I need some information on how to store the image in the blobfield and retrieve it.
If this blck code doesn't store the image in the blobfield and just the path I need some tutorial or example to help me understand.
Thanks for the help.

please explain why you think, you have to store the image as blob and why it is not sufficient to store only the path to the image...

as you are using a local database, usually the image still is available on the device under that path...
storing the image as blob needs a lot of memory... why storing the image again in the database when it already is there on the device?

Taifun

Thanks for your response .
I was thinking i need to store it in the database so I can back up the database and all info and images will be backed up in the database.
I really appreciate your help.
I have used Turbo Pascal to program in the past and i allways stored all info and images in the database.

Is there a tutioral that shows the storing and retrieval of images and there paths here for ai2 ?

Before storing the image as blob in the database, you have to convert it into a blob...

You can use one of the following methods
using the webviewer and some JavaScript

using an extension

There might also be other method, see also Search results for 'Blob' - MIT App Inventor Community

Taifun

Thanks so much for the help Taifun . I really like this platform . I am trying to learn it.