Have been successful with the httputils example that downloads the android icon and sets it as activity background. Next hurdle -- instead of an image, I want to download a sqlite file from the server and copy it to DirDefaultExternal. I am stuck.
There is no difference between downloading an image or downloading any other file.
I guess that you are stuck in the copy step.
You can copy the downloaded resource by using HttpUtils.GetInputStream with File.Copy2.
Don't forget to close the output stream.
So much of that code in the httputils example was very confusing to me, so I was able to figure out just what part I needed to get the file from the server. I put a button on main to start the process. I rem'd out the code that sets the downloaded image to the background so you can see what I did. Added the code you said, but I don't know what to put in after file.copy2
Thanks for you assistance.
B4X:
Sub Button1_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", ImageUrl)
End Sub
Sub JobDone (Job As String)
If HttpUtils.IsSuccess(ImageUrl) Then
'Dim b As Bitmap
'b = HttpUtils.GetBitmap(ImageUrl)
'Activity.SetBackgroundImage(b)
Dim filename As String
filename=HttpUtils.GetInputStream(ImageUrl)
File.Copy2(what goes here??)
End If
End Sub
Thank so much, Erel. Got it going now. This is just another step in learning how to setup and implement push notification to update the tablets. Is it possible to use this code to download a file from a local computer rather than a web server?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.