Android Question Remote Database Connector- how to pass Picture in SqlLite Database ?

alienhunter

Active Member
Licensed User
Longtime User
Hi to All ,
did anyone saved a picture with RDC Client ?

I am able to save texts but how can i save a picture ?
I know it should be a "blob" put how can i pass the information to sqllite database ?
The Database Column is a blob too

B4X:
Sub putjob
  Dim cmd As DBCommand
  cmd.Initialize
  cmd.Name = "insert_animal"
  cmd.Parameters = Array As Object(jobnr1.Text, ??? PICTURE ???? ) ??? here what  ? 
  reqManager.ExecuteCommand(cmd,1)
 
End Sub

thanks AH
 

alienhunter

Active Member
Licensed User
Longtime User
Got it to work

B4X:
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets,"7.jpg")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    Log(" Buffer " & Buffer.Length)

   cmd.Initialize
   cmd.Name = "insert_animal"
    
   cmd.Parameters = Array As Object(jobnr1.Text,Array As Object(Buffer) )
   reqManager.ExecuteCommand(cmd,1)
 

Attachments

  • sqllite.jpg
    sqllite.jpg
    129.6 KB · Views: 255
Upvote 0

alienhunter

Active Member
Licensed User
Longtime User
It is actually simpler. There is a method named DBRequestManager.FileToBytes that reads a file and returns it as an array of bytes.

Note that I change the thread title to Remote Database Connector to avoid confusion (this is the correct name).

I changed the Title (sorry ..)

Thanks
and i missed this one from the codemodule
B4X:
    Buffer=reqManager.FileToBytes(File.DirAssets,"7.jpg")
works

AH
 
Upvote 0
Top