Update App using FTP

fatman

Active Member
Licensed User
Longtime User
Hi Folks,

I have written an app for my salesmen. I have no problems downloading sqlite-tables and updating all the necessary data.
But is there a way updating the app by ftp too? I have changes nearly every week. I do not want to publish the app its for internal use only.

Any hints or ideas are welcome.

Thanks Fatman.
 

Nickelgrass

Active Member
Licensed User
Longtime User
Update App from http

Hi,
im quite new to b4a and am very interested in including an update function from my website.
I thought of putting a version file next to the apk file in an folder on my website and have the app compare it with an internal version number. Does this make sense? How does one usually do this?
Also I would need some more directions to downloading the new app (via simple HTTP and not FTP) and then replace the old one by installing it and then delete the temporary downloaded app. Can I simply use the HTTP client to get it and then store the responsetext as .APK file? Is there any "nicer" way to do this?
Thanks a lot!
 
Last edited:
Upvote 0

DouglasNYoung

Active Member
Licensed User
Longtime User
Nickelgrass,
You can simply use HttpUtils.Download & HttpUtils.GetString

1) Holding the current version number in simple text file on your web server
2) Download this file with HttpUtils.Download
3) Read contents with HttpUtils.GetString
4) Check against installed version
5) If installed < current then
6) Download new 'apk' file with HttpUtils.Download
6) Install

Douglas
 
Upvote 0

Nickelgrass

Active Member
Licensed User
Longtime User
So far everything is working except one thing. I am using the Httprequest and initializeget to download the apk file. But the filesize I am receiving in the Response.GetString("UTF8") is not the correct size (it is ~99K instead of ~105K).
When I download the file from Android browser the size is ok. What am I doing wrong. (I do not want to use the Httputils.)
Thanks a lot!
 
Upvote 0

Nickelgrass

Active Member
Licensed User
Longtime User
Thanks for the replies!
In case anyone is interested I would like to share the solution:
I looked into the Httputils and simply used the same method in my app with Response.getasynchrounously. That worked fine and is simple.

:sign0060:
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
Please do! I have been working on this for about 3 hours and just can't seem to wrap my head around it. I have the apk file on my server and I THINK I am downloading it but am not sure.
 
Last edited:
Upvote 0

elck

Member
Licensed User
Longtime User
Yes. You can download the APK file, copy it to the storage card and then send an intent that will install it.

I used
B4X:
Dim b As String
b=UpdateJob.GetString
File.WriteString(File.DirDefaultExternal, name,b)

to copy the file, but I think that here things went wrong as I should not use ASCII but Binary mode? (I get a parser error)
In other words, how do I copy the file from job.getstring to the SD card?
 
Upvote 0

elck

Member
Licensed User
Longtime User
Thanks Erel, that makes sense.
Mh Dropbox, hadn't thought of that either, might be some use for that too somtimes..
 
Upvote 0

consultatech4android

Member
Licensed User
Longtime User
Yes. You can download the APK file, copy it to the storage card and then send an intent that will install it.

This is the intent:
B4X:
Dim i As Intent
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal, "temp.apk"))
i.SetType("application/vnd.android.package-archive")
StartActivity(i)


It was what I needed also
 
Upvote 0

GlenAlan

Member
Licensed User
Longtime User
Hi Nickelgrass. Did you ever share the solution to update an APK using FTP? I don't see any attachments on this thread. I'm struggling with this and would appreciate an example.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Hi Folks,
I do not want to publish the app its for internal use only.

You can setup an Google-Dev-Account and then you can put the App in beta-status and then you can Publish it for selected persons. But the app seems to have to be always beta i i read that correctly on googles Website.

Regards, Manfred
 
Upvote 0
Top