'How to create a directory or set path to download folder in android 10 and above?

I have a app which have it's own downloader

Upto android 9 I'm using below code to set path to specific directory

File  file = new File(Environment.getExternalStorageDirectory().getPath() + "/Custom folder");
 if (!file.exists()) 
 {
 boolean f = file.mkdir();
 }

But with storage policy change this code doesn't work properly.

I tried

All files access permission

But App got rejected by Google and They suggested me to use Media store API , I read Media store API documentation but I didn't find the way to set path to download folder.

So any solution to create a distinguish directory or at least a way to set path to android Download folder?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source