Android Question Insert photo in SQLite database

walterf25

Expert
Licensed User
Longtime User
Greeting and respect, dear friends.
How can I insert photo & video to the SQLite database?
This is how I do it, I know there may be other more elegant ways to do it, but I have been using this code for sometime now.
Insert Image into DataBase:
private Sub SaveBlob(Column As String, data() As Byte)
    Dim base64 As StringUtils
    Dim encoded As String
    encoded = base64.EncodeBase64(data)
    Dim query As String = $"UPDATE Registrations SET ${Column} = ${"'"&encoded&"'"} WHERE UserName = ${"'"&Starter.userName&"'"} AND PinNumber = ${"'"&Starter.pinNumber&"'"}"$
    Log(query)
    Common.mysql.AddNonQueryToBatch(query, Null)
    Dim SenderFilter As Object = Common.mysql.ExecNonQueryBatch("SQL")
    Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
    Log("pictured saved: " & Success)
End Sub

This basically turns the byte data into a very long base64 encoded string, this should probably get you started.
 
Upvote 0
Top