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 shared folder i.e. Downloads or Pictures Folder as per MediaStore API
Below are 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
Now question is I want example of How to download Image/Video file in Android R and save into download folder location with MediaStore.
from How to download image/video file in Android R with help of MediaStore?
No comments:
Post a Comment