我正在从服务器获取并将其下载到手机中。下载后,当我在手机图库中看到图像时,没有可用的图像,但是当我通过文件管理器看到图像时,在下载历史记录中它显示了图像。 / p>
我想在像instagram这样的Digi
文件夹等单独的文件夹名称中显示图库。
下面是我的代码:
String downloadUrlOfImage = "http://www.example.com/images/example.jpg";
String PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).
getAbsolutePath() + "/" + "Digi" + "/";
File direct = new File(PATH);
if(!direct.exists()){
direct.mkdir();
}
DownloadManager dm = (DownloadManager)context.getSystemService(Context.DOWNLOAD_SERVICE);
Uri downloadUri = Uri.parse(downloadUrlOfImage);
DownloadManager.Request request = new DownloadManager.Request(downloadUri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI)
.setTitle("Downloading " + img)
.setMimeType("image/jpeg")
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
.setDestinationInExternalFilesDir(context,PATH,img);
dm.enqueue(request);
请让我知道我做错了什么,我们将不胜感激。
谢谢