下载mp3并将其保存为字符串

时间:2016-05-20 09:05:55

标签: android audio encoding

我正在尝试使用以下代码下载带有下载管理器的mp3文件

try {
    URL url = new URL(VIDURL);
    URLConnection connection = url.openConnection();
    connection.connect();

    // Detect the file length
    int fileLength = connection.getContentLength();

    /* ......Download Manager...... */
    Uri uri = Uri.parse(VIDURL);

    // Download Manager Request
    DownloadManager.Request request = new DownloadManager.Request(uri);
    request.setDestinationInExternalPublicDir("/Android/data/" + getApplicationContext().getPackageName() + "/", extractLastWord(VIDURL));
    long ID = downloadManager.enqueue(request);
    downloadId = ID;
    db_obj.DetailsInsertion(extractLastWord(VIDURL), ID + "");
    try {
        mythread.destroy();
    } catch (Exception e) {
        callNewThread();
    }

} catch (Exception e) {
    // Error Log
    Log.e("Error", e.getMessage());
    e.printStackTrace();
}

此处文件以filename.mp3格式保存,下载完成后,我正在加密数据并保存文件,以便用户打开它。我的问题是用户可以打开它并在下载过程中使用。无论如何,我可以以任何其他方式将文件保存为字符串或其他东西,然后将其转换。

0 个答案:

没有答案