想要使用Uri將音樂文件存儲在getFilesDir()中。我曾試圖通過這種方式使用下載管理器將媒體存儲在內部存儲器中
Uri Download_Uri = Uri.parse(songBean.vSongsFileName);
DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
mDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setAllowedOverRoaming(false);
request.setTitle(songBean.vTitle);
request.setDescription("Downloading File");
try {
request.setDestinationUri(Uri.parse(createDirectory("tmp.mp3").getPath()));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
downloadReference = mDownloadManager.enqueue(request);
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
}
}, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
爲創建目錄的方法存儲內部存儲
public File createDirectory(String filename) throws FileNotFoundException {
File file = new File(context.getFilesDir(), filename);
Log.i("Tag", "createDirectory: " + file.getAbsolutePath());
return file;
}
無法將文件存儲在內部存儲器內。 request.setDestinationUri(Uri.parse(createDirectory("tmp.mp3").getPath()));
投擲not a file uri
error.Please help out for this
我看沒有問題的描述。也不是一個問題。 – greenapps
我遇到這種類型的問題,所以我發佈它,如果有人已經這樣做 –
你面對哪個問題?你沒有描述一個問題/問題。 – greenapps