I got this code that loops inside of a FireStore database, gets the URLs stored in there, and downloads it to my phone;
DatabaseReference mDatabaseReff = FirebaseDatabase.getInstance().getReference(placee).child("תמונות").child(year).child(eventcase.getCaseInfo()).child(getmonth1).child(nameGet1+ "-" + idGet1);
mDatabaseReff.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
mStoredPictures = new ArrayList<>();
if (snapshot.exists()) {
for (DataSnapshot postSnapShot : snapshot.getChildren()) {
StoredPicture storedPicture = postSnapShot.getValue(StoredPicture.class);
mStoredPictures.add(storedPicture);
storedPicture.getmImageUrl();
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(storedPicture.getmImageUrl()));
String title= URLUtil.guessFileName(storedPicture.getmImageUrl(),null,null);
request.setTitle(nameGet1+ "-" + idGet1);
request.setDescription("----");
String cookie=CookieManager.getInstance().getCookie(storedPicture.getmImageUrl());
request.addRequestHeader("cookie",cookie);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,title);
DownloadManager downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
downloadManager.enqueue(request);
Toast.makeText(SearchCase.this, "מוריד תמונות/סרטונים...", Toast.LENGTH_SHORT).show();
}
}
}
the code works but it puts all the files inside of the download folder. I want it to be put it inside a custom-made folder.
I tried to write;
request.setDestinationInExternalPublicDir("/folder/innerFolder",title);
but it just gives me the "Not one of the standard directories:" ERROR.