2016-08-05 28 views
1

私は、サーバーからAndroid DownloadManagerを使用してビデオをダウンロードしています。私は自分自身で各ビデオに名前を付けたいと思う。デフォルトでは、ビデオの名前はdownloadfile-6.binです。ダウンロードファイルに名前を付けるには

String servicestring = Context.DOWNLOAD_SERVICE; 
DownloadManager downloadmanager; 
downloadmanager = (DownloadManager) getSystemService(servicestring); 
Uri uri = Uri.parse(links.get(0)); 
DownloadManager.Request request = new DownloadManager.Request(uri); 
Long reference = downloadmanager.enqueue(request); 

提案があります。

答えて

2

オブジェクトで設定することができます。setDestinationInExternalFilesDir(...)またはsetDestinationInExternalPublicDir(...)です。

request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE) 
     .setAllowedOverRoaming(false) 
     .setTitle("DownloadTitle") 
     .setDescription("DownloadDesc") 
     .setDestinationInExternalPublicDir("/mypath", "filename.jpg"); 

出典:

+0

おかげ@Ugurcanイルディリム最後の行を参照してください。できます –

関連する問題