H hackhack Active Member Licensed User Longtime User Jun 23, 2011 #1 Can a string hold characters from 0 to 255 ascii? When the http library talks about reading things into 'strings' does that include binary files?
Can a string hold characters from 0 to 255 ascii? When the http library talks about reading things into 'strings' does that include binary files?
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2011 #2 You should not use strings to hold binary data. You should use a bytes array. Strings cannot hold all the possible values. Strings are much more complicated as they hold Unicode code points. Upvote 0
You should not use strings to hold binary data. You should use a bytes array. Strings cannot hold all the possible values. Strings are much more complicated as they hold Unicode code points.
H hackhack Active Member Licensed User Longtime User Jun 23, 2011 #3 Aww, the old days are really gone, eh. Ok 2 questions: How do i write them to a file then? Seems there is only file.WriteString not WriteBinary And, byte arrays can't be open ended right? You have to dim their size in advance of using them? Upvote 0
Aww, the old days are really gone, eh. Ok 2 questions: How do i write them to a file then? Seems there is only file.WriteString not WriteBinary And, byte arrays can't be open ended right? You have to dim their size in advance of using them?
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2011 #4 You can use OutputStream or RandomAccessFile to write the data. What are you trying to do, maybe their is a simple way to do it? Upvote 0
You can use OutputStream or RandomAccessFile to write the data. What are you trying to do, maybe their is a simple way to do it?
H hackhack Active Member Licensed User Longtime User Jun 23, 2011 #5 Erel said: You can use OutputStream or RandomAccessFile to write the data. What are you trying to do, maybe their is a simple way to do it? Click to expand... I'm trying to download an apk from a website, and once downloaded start the install to allow the user to update the app. I tried just launching the browser to the URL, and that sorta works, the apk gets downloaded, but I'm not sure if the download would always be in the same place. I can't be sure of the name necessarily, and I don't know how the app would know when the browser had finished. So I thought I should try and download it myself (so to speak) Upvote 0
Erel said: You can use OutputStream or RandomAccessFile to write the data. What are you trying to do, maybe their is a simple way to do it? Click to expand... I'm trying to download an apk from a website, and once downloaded start the install to allow the user to update the app. I tried just launching the browser to the URL, and that sorta works, the apk gets downloaded, but I'm not sure if the download would always be in the same place. I can't be sure of the name necessarily, and I don't know how the app would know when the browser had finished. So I thought I should try and download it myself (so to speak)
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2011 #6 This should not be too difficult. You are using HttpUtils, right? To copy a file you should use code similar to: Code: Copy Dim out As OutputStream out = File.OpenOutput(File.DirRootExternal, "1.apk", false) File.Copy2(HttpUtils.GetInputStream(...), out) out.Close Upvote 0
This should not be too difficult. You are using HttpUtils, right? To copy a file you should use code similar to: Code: Copy Dim out As OutputStream out = File.OpenOutput(File.DirRootExternal, "1.apk", false) File.Copy2(HttpUtils.GetInputStream(...), out) out.Close
H hackhack Active Member Licensed User Longtime User Jun 23, 2011 #7 Erel said: This should not be too difficult. You are using HttpUtils, right? Click to expand... Yes, I saw you said that was the easy way Erel said: To copy a file you should use code similar to: Code: Copy Dim out As OutputStream out = File.OpenOutput(File.DirRootExternal, "1.apk", false) File.Copy2(HttpUtils.GetInputStream(...), out) out.Close Click to expand... Thanks, I'll try that. Upvote 0
Erel said: This should not be too difficult. You are using HttpUtils, right? Click to expand... Yes, I saw you said that was the easy way Erel said: To copy a file you should use code similar to: Code: Copy Dim out As OutputStream out = File.OpenOutput(File.DirRootExternal, "1.apk", false) File.Copy2(HttpUtils.GetInputStream(...), out) out.Close Click to expand... Thanks, I'll try that.
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2011 #8 See B4A-Bridge source code for an example of installing a saved apk: Basic4android Search: B4A Bridge source code Upvote 0
See B4A-Bridge source code for an example of installing a saved apk: Basic4android Search: B4A Bridge source code
H hackhack Active Member Licensed User Longtime User Jun 24, 2011 #9 Your example code further up worked excellently Upvote 0