Android Question Downloading files is inconsistent

Carthalion

Member
Licensed User
Longtime User
Downloading files works, but not all files every time. There are 24 downloads. Sometimes it downloads all the files but sometimes only half.

Is there a way to make this more consistent? Only downloading six and a time?

Another idea...is there a way to pre-install these files in DirRootExternal as part of the .apk file?

Also, I tried to use the code editor. Sorry about that. Next time, I hope.

Sub GetFiles
Dim job1 As HttpJob
job1.Initialize("job1", Me)
job1.Download("http://www.mysite.com/" & FolderName & "/textfiles/InetLolo.txt")

Dim job2 As HttpJob
job2.Initialize("job2", Me)
job2.Download("http://www.mysite.com/" & FolderName & "/textfiles/InetLo.txt")

End Sub

Select job.jobName
Case "job1"
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "QQFiles/InetLolo.txt", False)
File.Copy2(job.GetInputStream, out)
out.Close

Case "job2"
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "QQFiles/InetLo.txt", False)
File.Copy2(job.GetInputStream, out)
out.Close
End Select
 
Last edited:
Please use option where you insert code:

upload_2016-12-10_19-6-55.png
 
Upvote 0
Look THIS Thread.

Your error is here:

Code: Copy
File.OpenOutput(File.DirRootExternal, "QQFiles/InetLimits.txt", False)

upload_2016-12-10_19-14-40.png

so i think ( you must try )

Code: Copy
File.OpenOutput(File.DirRootExternal & "/QQFiles/", "InetLimits.txt", False)
 
Upvote 0
Anyway for future when you insert new Thread, pls, write more information type: what you see in LOG WINDOWS, etc.
 
Upvote 0
Look THIS Thread.

Your error is here:

Code: Copy
File.OpenOutput(File.DirRootExternal, "QQFiles/InetLimits.txt", False)

View attachment 50852
so i think ( you must try )

Code: Copy
File.OpenOutput(File.DirRootExternal & "/QQFiles/", "InetLimits.txt", False)

I did try this and it has too many parameters. I appreciate your response however.

Additionally, I found something that might help explain. When I step through the code, all 24 files are read and then written. Any idea why this would matter? Or any ideas about how to pursue this as a solution?
 
Upvote 0
You can place them in your FILES folder and on appstart copy them to the folder you want (if not already exists)
This does solve my dilemma. I do not know why, but if the files are already there, then they will read and rewrite again every time.
 
Upvote 0

Similar Threads

  • Locked
  • Article Article
Android Code Snippet [B4X] DownloadAndSave
Replies
2
Views
10K
Replies
36
Views
137K
Replies
196
Views
158K
Back
Top