gpt4 book ai didi

android: downloadmanager 文件存储在哪里

转载 作者:行者123 更新时间:2023-11-29 19:46:33 25 4
gpt4 key购买 nike

我刚开始在 android 中使用 downloadmanager。我正在使用 genymotion 模拟器。

我正在尝试使用 downloadmanager 下载 mp3 文件。我想知道下载后文件存储在哪里。

Environment.getExternalStorageDirectory()

它显示/storage/emulated/0。它是共享的“外部存储”

我也查过

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

它指向 /storage/emulated/0/Download 。 mp3 文件不在那里。

我还检查了/storage/emulated/0/Android/data/com.simha.sacredindaapp。 mp3 文件不存在。

我下载mp3文件的代码是:

DownloadManager downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
Uri uri = Uri.parse("http://audio.iskcondesiretree.com/02_-_ISKCON_Swamis/ISKCON_Swamis_-_R_to_Y/His_Holiness_Radhanath_Swami/Lectures/00_-_Year_wise/Devotional_Nectar_-_2016/2016-01-31_Various_-_Vrindavan_is_Perceived_by_Our_Consciousness-For_Ukraine_Devotees_-_Radhanath_Swami.mp3");
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDescription("My Download").setTitle("Notification titile");
downloadManager.enqueue(request);

最佳答案

您需要设置一个目标目录。

DownloadManager downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
Uri uri = Uri.parse("http://audio.iskcondesiretree.com/02_-_ISKCON_Swamis/ISKCON_Swamis_-_R_to_Y/His_Holiness_Radhanath_Swami/Lectures/00_-_Year_wise/Devotional_Nectar_-_2016/2016-01-31_Various_-_Vrindavan_is_Perceived_by_Our_Consciousness-For_Ukraine_Devotees_-_Radhanath_Swami.mp3");
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDescription("My Download").setTitle("Notification titile");

// change the name file and your current activity.
request.setDestinationInExternalPublicDir(MainActivity.this, Environment.DIRECTORY_DOWNLOADS, "test.jpg");

downloadManager.enqueue(request);

关于android: downloadmanager 文件存储在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37520344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com