I try to save a company logo as a .jpg file in an SQL DB and then load this logo into an image viewer.
Property while looking for some examples of Android found, but nothing right for B4J.
For the store I wrote a code, but do not know if it is correct.
Who has an example or can check my code and supplement it?
Property while looking for some examples of Android found, but nothing right for B4J.
For the store I wrote a code, but do not know if it is correct.
Who has an example or can check my code and supplement it?
B4X:
Private Logo_Pfad, Logo_Name As String
Dim FC As FileChooser
FC.Initialize
FC.Title = "Logo einfügen"
FC.InitialDirectory = "C:\"
' Dim DirChosen As String
FC.SetExtensionFilter("Image",Array As String("*.jpg","*.png","*.bmp"))
Dim FileChosen As String
FileChosen=FC.ShowOpen(frm)
'convert the image file to a bytes array
Dim InputStream1 As InputStream
InputStream1 = File.OpenInput("", FileChosen)
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
SQL_DB.InitializeSQLite(File.DirApp,"Alle_Betriebsdaten.db", True)
SQL_DB.ExecNonQuery("UPDATE Firma_Grunddaten SET Logo_Name = 'Logo', Logo_Image = '" & Array As Object(Buffer) & "'")
Last edited: