Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private WebServer As String = "https://rose.myddns.me"
Private ISFolder As String = xui.DefaultFolder
Private FileName As String = "Summer.jpg"
Private ASFolder As String File.DirRootExternal & "/Download"
Sub Download
Dim HTTP1 As HttpJob
Dim ServerPath As String = WebServer & "/" & FileName
HTTP1.Initialize("", Me)
HTTP1.Download(ServerPath)
Wait For (HTTP1) JobDone(HTTP1 As HttpJob)
If HTTP1.Success Then
Log("File was downloaded successfully")
Dim out As OutputStream = File.OpenOutput(ISFolder, FileName, False)
File.Copy2(HTTP1.GetInputStream, out)
out.Close '<------ very important
Log("File was copied successfully to Internal Storage")
Else
Log(HTTP1.GetString)
Log("Error downloading file")
End If
HTTP1.Release
Sleep(0)
File.Copy(ISFolder, FileName, ASFolder, FileName)