As getExternalStoragePublicDirectory has been deprecated in Android Q and recommendation is to use MediaStore
API
Here is my Image URL https://cdn.pixabay.com/photo/2020/04/21/06/41/bulldog-5071407_1280.jpg
I want to download this image file and want to save the shared folder i.e. Downloads or Pictures Folder as per MediaStore
API
Below is the sample code
ContentResolver resolver = context.getContentResolver();
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, name);
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, mimeType);
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS);
Uri uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
Note: compileSdkVersion 30
I want an example of How to download an Image/Video file in Android R and save it into the download folder location with MediaStore.