Wait is not waiting so I guess i'm doing something wrong.
When my app loads it needs to check the database is present if not it must download it.
This is what I am trying. As soon as it hits the wait statement line 51 it returns to Activity_Create and doesn't wait
When my app loads it needs to check the database is present if not it must download it.
This is what I am trying. As soon as it hits the wait statement line 51 it returns to Activity_Create and doesn't wait
B4X:
Activity.LoadLayout("Intro")
DBFileDir = rp.GetSafeDirDefaultExternal("") 'File.DirDefaultExternal
If FirstTime Then
If File.Exists(DBFileDir, "helper.db") = False Then
If Msgbox2("About to download the current Database 5.2mb?","Database Download","Yes","","Not Now",Null) = DialogResponse.POSITIVE Then
awake.KeepAlive(True)
ProgressDialogShow2("Please wait",False)
downloadDatabase
ProgressDialogHide
awake.ReleaseKeepAlive
Else
ToastMessageShow("Can't continue without database", True)
ExitApplication
End If
End If
End If
End Sub
Sub downloadDatabase
Dim j As HttpJob
j.Initialize("", Me)
j.Username = "XXXXXX"
j.Password = "XXXXX"
j.Download("https://www.XXXXX.com/Larastuff/helper.db")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(DBFileDir, "helper.db", False)
File.Copy2(j.GetInputStream, out)
out.Close '<------ very important
End If
End Sub