eu uso uma classe para fazer download de ficheiros
mas o url não é do tipo
http://site.php?ficheiro.rar
o url é http://site.php?ficheiro=download
onde é precisso usar o metodo Post para fazer o download do ficheiro.
mas o problema é que por vezes o ficheiro é rar e outras vezes é .zip
protected String doInBackground(String... aurl) { try { HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("[url="http://www.legendas-zone.org/downloadsub.php"]http://www.legendas-...ownloadsub.php"[/url]); httpPost.addHeader("Cookie", login.cooklogin); BasicNameValuePair usernameBasicNameValuePair = new BasicNameValuePair("sid", aurl[0]); BasicNameValuePair passwordBasicNameValuePAir = new BasicNameValuePair("action", "download"); List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>(); nameValuePairList.add(usernameBasicNameValuePair); nameValuePairList.add(passwordBasicNameValuePAir); UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(nameValuePairList); httpPost.setEntity(urlEncodedFormEntity); HttpResponse httpResponse = httpClient.execute(httpPost); long lenghtOfFile = httpResponse.getEntity().getContentLength(); FileOutputStream f = new FileOutputStream(new File(Environment.getExternalStorageDirectory() + "/download/", aurl[1])); InputStream in = httpResponse.getEntity().getContent(); byte[] buffer = new byte[1024]; int len1 = 0; long total = 0; while ((len1 = in.read(buffer)) > 0) { total += len1; publishProgress("" + (int)((total*100)/lenghtOfFile)); f.write(buffer, 0, len1); } f.close(); } catch (Exception e) { Log.d("Downloader", e.getMessage()); } return null; }