collection = getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY) val collectionWithPending = MediaStore.setIncludePending(collection) resolver.query(collectionWithPending).use { // Get a specific media item uri ContentUris.withAppendedId( collection, it.getLong(it.getColumnIndex(ImageColumns._ID)) ) }.let { // Open a specific media item resolver.openFileDescriptor(Uri.parse(it), "w").use { // ... do something } }
collection = getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY) val collectionWithPending = MediaStore.setIncludePending(collection) resolver.query(collectionWithPending).use { // Get a specific media item uri ContentUris.withAppendedId( collection, it.getLong(it.getColumnIndex(ImageColumns._ID)) ) }.let { // Open a specific media item resolver.openFileDescriptor(Uri.parse(it), "w").use { // ... do something } }
collection = getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY) val collectionWithPending = MediaStore.setIncludePending(collection) resolver.query(collectionWithPending).use { // Get a specific media item uri ContentUris.withAppendedId( collection, it.getLong(it.getColumnIndex(ImageColumns._ID)) ) }.let { // Open a specific media item resolver.openFileDescriptor(Uri.parse(it), "w").use { // ... do something } }