URL url = newURL(http://somewhere.com/some/webhosted/file);
HttpURLConnectionurlConnection = (HttpURLConnection) 
url.openConnection(); 
urlConnection.setRequestMethod("GET"); 
urlConnection.setDoOutput(true); 
urlConnection.connect(); 
File SDCardRoot = Environment.getExternalStorageDirectory(); 
File file = new File(SDCardRoot,"somefile.ext"); 
FileOutputStream fileOutput = new FileOutputStream(file); 
InputStream inputStream = urlConnection.getInputStream();
int totalSize = urlConnection.getContentLength(); 
pd.setMax(totalSize);//ProgressDialog  pd
int downloadedSize = 0; 
byte[] buffer = new byte[1024]; 
int bufferLength = 0;
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
    fileOutput.write(buffer, 0, bufferLength); 
    downloadedSize += bufferLength; ;
    pd.setProgress(downloadedSize);//ProgressDialog  pd
}
原文:http://blog.csdn.net/berber78/article/details/42044817