Android Question Displaying a Image from SQLite Blob

Terradrones

Active Member
Hi All

Ok, I have managed to display my Topo info from the SQlite Database in a B4XTable without crashing even if there is an Image stored in the Database.

I have a Panel in which I display the Table with the Topo Info and when I click on a Colom number the "Pic" Button becomes visible, which is supposed to show me the Image associated with that Topo Shot.

When I click on this Button, it gives me this error message:

android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1

My Code:

Display Image:
Sub PicList_Click
    ShowScreens
    Panel2.Visible=True
    
    Try
        Dim Cursor1 As Cursor = CGlobals.SQL1.ExecQuery2("SELECT Image FROM Topo WHERE No = ?", Array As String(RowId1))
        Cursor1.Position = 0
        Dim Buffer() As Byte = Cursor1.GetBlob("Image")
        Dim InputStream1 As InputStream
        InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
        Dim Bitmap1 As Bitmap
        Bitmap1.Initialize2(InputStream1)
        InputStream1.Close
        Panel3.SetBackgroundImage(Bitmap1)
    Catch
        Label1.Visible=True
    End Try
End Sub

Any kick in the right direction please?
 

MicroDrie

Well-Known Member
Licensed User
android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1
It looks that, based on "totalRows=1" part of the error, that you change the result of a previous query into a new query of the database. I think that is your mistake. I think that you should take the already loaded image from the table based on row / column location and propose the already loaded image from that location. Maybe this [B4X] B4XTable with custom cells layout may inspire you.
 
Upvote 0

Terradrones

Active Member
Hi All

OK, I have decided to follow the route that Erel has suggested, as an Image with a maximum size of 2Mb is not very large. Each Topo Survey is stored in a Folder that has the same name as the Job Name. In this Folder the Topo Survey is stored in an SQLite Database. Each Topo Shot taken has a unique number which is tied to a counter. If the Surveyor takes a Picture and its say Point number 234 that will be recorded, I will name the Picture "234.jpg". These Images will be stored in a Sub-Folder in the Job Folder.

When the Surveyor lists the Points in a Table and highlights say Point no 112 and clicks the "Pic" Button, the Program will display Image "112.jpg". The same is where the Points are plotted, the Surveyor can click the "Info" Button and then click on a plotted Point and the Program will display the coordinates of the selected Point together with the Image if the Image exists.
 
Upvote 0
Top