Q:

Android- Download mp3 to SDCARD via URL naming issue

I currently have a webview with various mp3 links. If the user presses on one of these links, an alertDialog will pop up and they can choose whether to listen or download the file. While my download portion works intended (via an asynctask), I have it currently set up where I specify the name which the mp3 file on the SDCARD will be called. I would like to have it so that the name of the track is the name of the mp3 file. Any ideas on how I could do that? Thanks.
Here is portion of my code:
//so you can click on links in app and not open the actual browser. will stay in app
    private class HelloWebViewClient extends WebViewClient{     
        @Override
        public boolean shouldOverrideUrlLoading(final WebView view, final String url){
            view.loadUrl(url);
            view.getSettings().getAllowFileAccess();
            view.getSettings().setJavaScriptEnabled(true);
            //load the dropbox files so people can listen to the track
            if(url.endsWith(".mp3")){
                progressWebView.dismiss();
                progressWebView.cancel();
                blogDialog.setButton("Listen", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent = new Intent(Intent.ACTION_VIEW);
                        intent.setDataAndType(Uri.parse(url), "audio/*");
                        view.getContext().startActivity(intent);

                    }
                });
                blogDialog.setButton2("Download", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        sdrUrl = url.toString();
                        new DownloadFile().execute();   

                    }   

                });
                blogDialog.show();

            }else{
                return super.shouldOverrideUrlLoading(view, url);
            }
            return true;
        }
    }

    //to handle the back button 
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event){
        if((keyCode == KeyEvent.KEYCODE_BACK) && sdrWebView.canGoBack()){
            sdrWebView.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    public void onPause(){
        super.onPause();
    }

    /*create the pop up menu so you can reload*/
    @Override
    public boolean onCreateOptionsMenu(Menu menu){
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item){
        switch (item.getItemId()){
        case R.id.refreshsetting: sdrWebView.loadUrl("http://www.stopdroprave.com");
        break;
        }
        return true;
    }

    private class DownloadFile extends AsyncTask<String, Integer, String>{
        @Override
        protected String doInBackground(String... url) {
            try {
                URL url2 = new URL(sdrUrl);
                HttpURLConnection c = (HttpURLConnection) url2.openConnection();
                c.setRequestMethod("GET");
                c.setDoOutput(true);
                c.connect();

                int lengthOfFile = c.getContentLength();

                String PATH = Environment.getExternalStorageDirectory()
                        + "/download/";
                Log.v("", "PATH: " + PATH);
                File file = new File(PATH);
                file.mkdirs();

                 String fileName = "testSDRtrack.mp3";

                File outputFile = new File(file, fileName);
                FileOutputStream fos = new FileOutputStream(outputFile);

                InputStream is = c.getInputStream();

                byte[] buffer = new byte[1024];
                int len1 = 0;
                while ((len1 = is.read(buffer)) != -1) {
                    publishProgress((int)(len1*100/lengthOfFile));
                    fos.write(buffer, 0, len1);
                }
                fos.close();
                is.close();

                }catch (IOException e) {
                       e.printStackTrace();
                }

            return null;
        }

        @Override
        protected void onProgressUpdate(Integer... values) {

            super.onProgressUpdate(values);
        }

}
}

A:

I essentially split the url and got the portion that I wanted then saved it like that
Android- split URL string

