Android Question JSONParser for Image data type

Imran_Farooq

Member
Licensed User
hi,
it is possible to getting some image (BLOB) type data from JSONParser

actually i want to be extract image type data field from remote server into local sqlite database. my code is as under

-------------------------------------------------------------------------------------------------------
Private NewRegistrationUrl As String = db_server & "/NewRegistration.aspx"

Job1.PostString(NewRegistrationUrl, "select IDNO,NAME,IMAGE from profile ")

job1.GetRequest.Timeout=30000
Wait For (job1) JobDone(job1 As HttpJob)
If job1.Success Then
''Log(job2.GetString)
Dim parser As JSONParser
Dim response As String = job1.GetString
parser.Initialize(response)
Dim rows As List
rows = parser.NextArray

'''work with result
'''rows is a List. Each item is a Map with the columns names as keys and the db values as the values.

''Log(rows.Size)

If rows.Size = 0 Then
ProgressDialogHide
ToastMessageShow("Record Not Found!",True)', True, Colors.Green)
Return
End If

For i = 0 To rows.Size - 1

Dim m As Map
m = rows.Get(i)
Log("col1=" & m.Get("IDNO")) 'log the values of col1 and col2
Log("col2=" & m.Get("NAME"))
Log("col3=" & m.Get("IMAGE")) 'log the values of col1 and col2

Dim Bmp As Bitmap = m.Get("IMAGE")
Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
Bmp.WriteToStream(OutputStream1, 90, "JPEG")
Dim Buffer() As Byte = OutputStream1.ToBytesArray
SQL1.ExecNonQuery2("INSERT INTO profile VALUES (?, ?, ?)", Array As Object(m.Get("IDNO"),m.Get("NAME"),Buffer))
'SQL1.ExecNonQuery2("INSERT INTO profile VALUES (?, ?, ?)", Array As Object(m.Get("IDNO"),m.Get("NAME"),m.Get("IMAGE")))
Next
Else

Return

End If
job1.Release
ProgressDialogHide
 

ilan

Expert
Licensed User
Longtime User
instead of blob you may use base64 to convert your image and save it as string in your database.
you can also upload your image to a folder on your server and save the link to that image and download it via http job.

 
Upvote 0
Top