I am trying to download a zipped file from the web on the first instance of the application; can someone point me to a tutorial for this (I don't see good documentation on developer.android)? I understand how to check if it's the initial start or not, and also how to use java.util.zip once I get the file, but it's the in-between where I'm lost.
A:
I think your question is about how to download the file. So, to download a file, use code similar to the following:
URL u = new URL("http://www.example.com/downloadfile.zip");
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
FileOutputStream fNew = new FileOutputStream(new File(root,"downloadfile.zip"));
InputStream inStream = c.getInputStream();
byte[] buffer = new byte[1024];
int inlen = 0;
while ( (inlen = inStream.read(buffer)) > 0 ) {
fNew.write(buffer,0, inlen);
}
fNew.close();
inStream.close();
Of course, wrap with appropriate error checking
Noah
2010-10-02 14:46:50