Android Question Read SQLite Blob field and insert it into MySQL

dhernandez

Active Member
Licensed User
Longtime User
Good morning Colleagues, I have the following problem ...
I am working with SQLite and MySQL ...
I take a picture with the camera and put it in SQLite, then do a query to extract the image and insert in MySQL remote via a PHP script.
The detail is when I try to view the images transferred to MySQL, I just transfers them about 60 Bytes for all the images and do not see anything, and the original image weighs 210KB ... I'm doing wrong to download?

I need your help much
 

dhernandez

Active Member
Licensed User
Longtime User
Thanks for answering and your interest ..

My code is as follows


Here convert the image to save in SQLite (Local)
B4X:
'Convert image into a Byte Array
        Dim InputStream1 As InputStream
        InputStream1 = File.OpenInput(File.DirRootExternal & "/" & "DCIM", Txt_OCR.Text & dt1 & ".jpg")
      
        Dim OutputStream1 As OutputStream
        OutputStream1.InitializeToBytesArray(1000)

        File.Copy2(InputStream1, OutputStream1)
          
        Dim Buffer() As Byte
        Buffer = OutputStream1.ToBytesArray

        'Save image to database as bytes
        SQL1.ExecNonQuery2("INSERT INTO imagen VALUES(?, ?)", Array As Object(Txt_OCR.Text,(Buffer)))

Here I make a query to retrieve the image and send it to MySQL (Remote)
B4X:
Dim IMG As String
        CURSOR1=SQL1.ExecQuery("SELECT * FROM Imagen")
        For i =0 To CURSOR1.RowCount -1
        CURSOR1.Position = i
                Dim NombreImagen As String
        Dim SU As StringUtils
        Dim ImagenCod As String   
        Dim Entrada As InputStream
        Dim Salida As OutputStream
        Dim GetImagen() As Byte
        Dim ImgCod As String
        NombreImagen =CURSOR1.GetString("OCR_I")
        GetImagen=CURSOR1.GetBlob("FotoEvidnc")
        Entrada.InitializeFromBytesArray(GetImagen, 0, GetImagen.Length)
IMG=SU.EncodeBase64(Entrada.InitializeFromBytesArray(GetImagen, 0, GetImagen.Length))
Entrada.Close
ImgCod = "Complemento"
        ExecuteRemoteQuery("INSERT INTO evidenciaext(NombreEvidencia, FotoEvidencia, CodImg) VALUES ('"& NombreImagen &"', '"& IMG &"', '"& ImgCod &"')",LISTA_INSPECCION)
    Next

I need your Help
 
Upvote 0

dhernandez

Active Member
Licensed User
Longtime User
Someone help me with this.
 
Upvote 0
Top