Android Question SQLite Insert/Update BLOB at specific position

Declan

Well-Known Member
Licensed User
Longtime User
Hi, the following code inserts a BLOB:
B4X:
SQL1.ExecNonQuery2("INSERT INTO table2 VALUES('smiley', ?)", Array As Object(Buffer))
However, I have a table that has 6 fields: id, img1, img2, img3, img4, img5

How can I insert the BLOB into a specific field, say "img3"?
Also, what would the syntax be to UPDATE / SET a BLOB in a specific field?

My code is:
B4X:
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "yelloe icone empty - copy.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database at position "img3"
 

Mvula

Member
Licensed User
Longtime User
For the insert it would be something like this:
B4X:
SQL1.ExecNonQuery2("INSERT INTO table2 (id, img3) VALUES ('1',?)", Arry as Object(Buffer))

For the UPDATE it would be like this:
B4X:
SQL1.ExecNonQuery2("UPDATE table2 SET img3 = ? WHERE id = 1", Arry as Object(Buffer))
thank you very much indeed, Declan
 
Upvote 0
Top