Since my images aren't too large, I am trying to save them on the database. However, I am still struggling to do this. This is my code so far.
Sub Globals
Dim bmp As Bitmap
Dim out As OutputStream
Dim inp As InputStream
End Sub
Sub Cam_PictureTaken (Data() As Byte)
out = File.OpenOutput(File.DirRootExternal, teamNumber.Text & ".jpg", False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
inp.InitializeFromBytesArray(Data, 0, Data.Length)
bmp.Initialize2(inp)
End Sub
I then save bmp to the database (in a column that is type: blob). Then this is my code to retrieve the picture. (It is inside a Select Case statement that gets the information back from the database)
Case "GetInfo"
Dim ListOfInfo As List
Dim TeamNumber As String
Dim TeamName As String
Dim Teampic As Bitmap
ListOfInfo = parser.NextArray
For i = 0 To ListOfInfo.Size - 1
Dim T As Map
T = ListOfInfo.Get(i)
TeamNumber = T.Get("ScoutedTeam")
If TeamNumber = ScoutedTeam Then
TeamName = T.Get("TeamName")
TeamNumber = T.Get("ScoutedTeam")
Teampic = T.Get("TeamPic") 'this is the code that should get the bitmap out of the database
InfoLabelNum.Text = TeamNumber
InfoLabelName.Text = TeamName
ImgViewTeamPic.SetBackgroundImage(Teampic)
End If
Next
When I run this code, I get this error message.
java.lang.RuntimeException: Object should first be initialized (Bitmap).
So, I'm assuming the bitmap Teampic needs to be initialized, but I don't know how I should initialize it. I tried doing this
But then I got this error message.
java.lang.RuntimeException: Object should first be initialized (InputStream).
So I am confused as to what I should I do.
Am I doing this the right way by just saving the bitmap into the database or should I be saving the input/output streams into the database?
Thanks for your help