protected String doInBackground(String... f_url) { int count; try { String root = Environment.getExternalStorageDirectory().toString(); System.out.println("Downloading"); URL url = new URL(f_url[0]); URLConnection conection = url.openConnection(); conection.connect(); int lenghtOfFile = conection.getContentLength(); InputStream input = new BufferedInputStream(url.openStream(), 8192); OutputStream output = new FileOutputStream(root+"/"+list.get(con_position)+".mp3"); byte data[] = new byte[1024]; long total = 0; while ((count = input.read(data)) != -1) { total += count; output.write(data, 0, count); } output.flush(); output.close(); input.close(); } catch (Exception e) { Log.e("Error: ", e.getMessage()); } return null; } @Override protected void onPostExecute(String file_url) { System.out.println("Downloaded"); pDialog.dismiss(); } } 

with the manifest everything is in order, in the doInBackground I pass the URL string to the resource. It seems the traffic goes but not for long, therefore there are no files, please help

  • Can you drop your stack track? Or at least that Log.e ("Error:", e.getMessage ()); displays? It is very important. - nick
  • What version of androyd? If it is 6th, then you probably forgot to write the rights to request from the user, starting with 6th, not only should you note some rights in the manifest, but also to check their availability using them and request them if they are not yet granted. - xkor
  • Yes, on the device 6 android, where you can read about it? - UjinUkr
  • An interesting situation, on the emulator 5.1.1 everything works, but I still don’t understand where it is stored - UjinUkr
  • Is there an error? Provide a template, please. If not, look for the file - Chubatiy

0