'Activity module
Sub Process_Globals
Dim fileUrl As String
fileUrl = "http://dl.dropbox.com/u/xxxxxx/db.db"
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
End Sub
Sub Activity_Resume
'Check whether a job has finished while the activity was paused.
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub UrlDone(Url As String)
Log(Url & " done")
End Sub
Sub JobDone (Job As String)
If HttpUtils.IsSuccess(fileUrl) Then
Log("Base de datos encontrada en la web")
HttpUtils.Download("GET Job1", fileUrl)
Dim In As InputStream, Out As OutputStream
In = HttpUtils.GetInputStream("GET Job1")
Out = File.OpenOutput(File.DirRootExternal & "/" & "external_sd", "db.db", True)
File.Copy2(In, Out)
Out.Close
HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
ExitApplication
End If
End Sub