Android Question BLOB - Null

Declan

Well-Known Member
Licensed User
Longtime User
I am loading images from a SQLite table, BLOB field.
If there in NO BLOB present (field is NULL), I need to load a generic image from File.DirAssets.
I am using the following, but cannot understand how to load the generic image file into the Buffer:
Code: Copy
Buffer = dbCursor.GetBlob("Image")
   
    If Buffer = Null Then
        Log("No Image In Table")
        Buffer = File.DirAssets,"BookBlank.jpg"
    End If
   
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    IV.SetBackgroundImage(Bitmap1)
 
maybe declare the generic bitmap in Globals and load at startup / prior to the sub ..

bmpBlank.Initialize(File.DirAssets,"BookBlank.jpg")

Then ...
Code: Copy
Buffer = dbCursor.GetBlob("Image")
If Buffer = Null Then
   Log("No Image In Table")
   IV.SetBackgroundImage(bmpBlank)
Else
   Dim InputStream1 AsInputStream
   InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
   Dim Bitmap1 AsBitmap
   Bitmap1.Initialize2(InputStream1)
   InputStream1.Close
   IV.SetBackgroundImage(Bitmap1)
End If
 
Last edited:
Upvote 0
Back
Top