需要帮助下载android mp3文件

|| 我正在向其中开发一个android应用程序,我需要下载mp3文件,但下载过程应在后台进行。有人对此有任何想法吗?     
已邀请:
终于我有了解决方案。
public void mp3load() {
        URL url = new URL(url);
        HttpURLConnection c = (HttpURLConnection) url.openConnection();
        c.setRequestMethod(\"GET\");
        c.setDoOutput(true);
        c.connect();

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

         String fileName = \"test.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) {
            fos.write(buffer, 0, len1);
        }
        fos.close();
        is.close();
} 对我有用。     
android:是否可以将给定xml(从URL)的文件下载到磁盘? 检查一下:带有downloadFileFrom方法的AsyncTask类将帮助您。     

要回复问题请先登录注册