Sub Button_InstallUpdate_Click
datasrc = "http://www.somewhere.com")
ToastMessageShow("Downloading Update - May take a minute or so. . .",True)
'Log("Database=" & datasrc)
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job2", dlfilename)
End Sub
Sub JobDone (Job As String)
Dim updatestatus As String
Dim In As InputStream, Out As OutputStream
If HttpUtils.IsSuccess(dlfilename) Then
Select Job
Case "Job1"
'......
Case "Job2"
' Handling input stream
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
If HttpUtils.IsSuccess(dlfilename) Then
In = HttpUtils.GetInputStream(dlfilename)
Out = File.OpenOutput(File.DirDefaultExternal, "update.db", False)
File.copy2(In,Out )
Out.Flush
Out.Close
File.copy(File.DirDefaultExternal,"workingfilename",File.DirDefaultExternal,"workingfilename.bak")
File.copy(File.DirDefaultExternal,"newfilename",File.DirDefaultExternal,"workingfilename")
'
ToastMessageShow("New Data downloaded OK!", False)
Else
ToastMessageShow("Problem Downloading Data!", False)
End If
End Select
Else
Button_InstallUpdate.Enabled = False
ToastMessageShow("Can't Connect to Server: Check Internet Connection or Try Later!",True)
End If
End Sub