Android Question Android BLOB Viewer Anyone?

epiCode

Active Member
Licensed User
I want to see the data file created by KVS for debugging.
It stores its values as BLOB and most of the sqlite viewers I tried did not show BLOB entries at all or even if they did, it was in hex.

Can someone suggest an android based Sqlite viewer which can show blob entries too ?
 

PaulMeuris

Active Member
Licensed User
Last year i wrote a tutorial about a SQLite database manager app: SQLite database manager
In this tutorial i try to get the contents of BLOBs.
Here is the code snippet:
B4X:
        Dim Buffer() As Byte  = rs.GetBlob(colid)
        Log(Buffer.Length)
        Dim InputStream1 As InputStream
        Dim bc As ByteConverter
        Dim hex As String = bc.HexFromBytes(Buffer)
        Log(hex)
        Dim InputStream1 As InputStream
        If hex.Contains("FFD8FF") Then        ' jpg, jpeg
            InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
        End If
        If hex.Contains("424D") Then        ' bmp
            InputStream1.InitializeFromBytesArray(Buffer, 8, Buffer.Length)
        End If
        If hex.Contains("47494638") Then    ' gif
            InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
        End If
        If hex.Contains("4D4D002A") Or hex.Contains("49492A00") Then    ' tiff
            InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
        End If
        If hex.Contains("89504E470D0A1A0A") Then    ' png
            InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
        End If
        Dim bmp As Bitmap
        bmp.Initialize2(InputStream1)
        InputStream1.Close
        ivphotodialog.Bitmap = bmp
        ivphotodialog.Gravity = Gravity.FILL
        pnl.AddView(ivphotodialog,0dip,0dip,340dip,490dip)
        Dim rsub1 As ResumableSub =  photodialog.ShowCustom(pnl, "OK", "", "")
        Wait For (rsub1) Complete (Result As Int)
        If Result = xui.dialogResponse_Positive Then
            '
        End If
There are more hex-strings you can test using the information from this webpage: List of signatures
Happy coding!
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Here is the code snippet:
Can someone suggest an android based Sqlite viewer which can show blob entries too ?
The OP is using KVS which has a method: KVS.getBitmap() to retrieve the bitmap from the store. Can someone tell me why he has to use the code in post #3 at all. I really don't think he needs it at all unless I am completely missing the objective.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
unless I am completely missing the objective
He is creating a hexstring from the blobdata to check for specific fileheaders to know what type of image is in the blob. Does not make any difference in building the Bitmap though.

at least one could use the code to check for png, jpgs or "anything other"
 
Upvote 0

epiCode

Active Member
Licensed User
The OP is using KVS which has a method: KVS.getBitmap() to retrieve the bitmap from the store. Can someone tell me why he has to use the code in post #3 at all. I really don't think he needs it at all unless I am completely missing the objective.

That's right @Mahares. If I have to write code to view, I could simple use the same KVS to return the BLOB value which wrote it in the first place.
I was looking for a quicker independent solution like a viewer which could show BLOB as hex & ascii (like good old hex viewers of MSDOS)
 
Upvote 0

teddybear

Well-Known Member
Licensed User
That's right @Mahares. If I have to write code to view, I could simple use the same KVS to return the BLOB value which wrote it in the first place.
I was looking for a quicker independent solution like a viewer which could show BLOB as hex & ascii (like good old hex viewers of MSDOS)
It is very easy to do that show BLOB as hex & ascii, you can use ByteConverter library to do.
B4X:
    Dim b() As Byte = Array As Byte(255, 254, 0, 1)
    Dim bc As ByteConverter
    Log(bc.HexFromBytes(b))
    'You will see the result FFFE0001'
 
Upvote 0
Top