Sdk Android 10 -

val uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues) resolver.openOutputStream(uri!!).use stream -> // write bitmap to stream

Example:

By following the guidelines in this document, you can ensure your app not only runs on Android 10 but thrives on it, while also being future-ready for later Android versions. sdk android 10