Android Question Convert into inputstream from a contentChooser into database

ProjectGroup19

Active Member
Licensed User
Longtime User
Please, how do convert an image selected from phone storage into an inputstream. So that i can store it in my database.
 
Code:
Dim bytes() As Byte = File.ReadBytes(Dir, FileName) 'event parameters

[CODE lang="b4x" highlight="7"]
Sub PP_Result(Success As Boolean, Dir As String, FileName As String)

If Success = True Then
Ppic.Bitmap = LoadBitmap(Dir,FileName)
Dim bytes() As Byte=File.ReadBytes(Dir,FileName)
Dim InputStream1 As InputStream=bytes
Dim OutputStream1 As OutputStream

OutputStream1.InitializeToBytesArray(1000)
File.Copy2(InputStream1, OutputStream1)
Dim Buffer() As Byte
Buffer = OutputStream1.ToBytesArray
Connection.db.ExecNonQuery2("UPDATE MEMBERSHIP set PIC= ? WHERE ACCOUNT='"&acc&"'", Array As Object(Buffer) )


Else
ToastMessageShow("Nothing Selected",True)
End If

End Sub[/CODE]

error: incompatible types: byte[] cannot be converted to InputStreamWrapper
_inputstream1 = (anywheresoftware.b4a.objects.streams.File.InputStreamWrapper)(_bytes);
^

All im trying to do is; after selecting a picture in phone storage, then the selected picture is saved in the database.
 
Upvote 0
All im trying to do is; after selecting a picture in phone storage, then the selected picture is saved in the database.
Did you try something like this:
Code:
    If Success  Then
        Dim Buffer() As Byte=File.ReadBytes(Dir,FileName)
        Connection.db.ExecNonQuery2("UPDATE MEMBERSHIP set PIC= ? WHERE ACCOUNT=?", Array As Object(Buffer, acc))
    Else
        ToastMessageShow("Nothing Selected",True)
    End If
 
Last edited:
Upvote 0
Did you try something like this:
Code:
    If Success  Then
        Dim Buffer() As Byte=File.ReadBytes(Dir,FileName)
        Connection.db.ExecNonQuery2("UPDATE MEMBERSHIP set PIC= ? WHERE ACCOUNT=?", Array As Object(Buffer, acc))
    Else
        ToastMessageShow("Nothing Selected",True)
    End If
it worked perfectly. Thank you. :)
 
Upvote 0
Back
Top