MediaStore.Images.Media.InsertImage is deprecated
MediaStore.Images.Media.InsertImage is deprecated
Hello,
Welcome to our Microsoft Q&A platform!
The Media.InsertImage method was deprecated in API level 29. Try using ContentValues class to achieve the function instead.
if (Build.VERSION.SdkInt >= BuildVersionCodes.Q)
{
var contentValues = new ContentValues();
contentValues.Put(MediaStore.MediaColumns.DisplayName, file_name);
contentValues.Put(MediaStore.Files.FileColumns.MimeType, "image/png");
contentValues.Put(MediaStore.MediaColumns.RelativePath, Android.OS.Environment.DirectoryPictures + "relativePath");
contentValues.Put(MediaStore.MediaColumns.IsPending, 1);
}
Similar issue: https://stackoverflow.com/a/57737524/11083277
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Thank you Jarvan.
but the Media.InsertImage can insert bitmap to the Pictures but ContentValues can not.
Media.InsertImage has two different ways: passing bitmap and path to insert the image. ContentValues doen't provide the code to handle the bitmap, please get the path from the image and pass the path to the ContentValues to perform the work.
Hi, @6666666
I have not heard from you for a couple of days. Please let me know if there is anything that I can help here.
8 people are following this question.