Created
December 7, 2022 17:54
-
-
Save rajumark/27327b4eb9c5744de704b392981646b0 to your computer and use it in GitHub Desktop.
pick folder using system tree view then use it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val dirRequest = | |
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri: Uri? -> | |
uri?.let { folderUri -> | |
contentResolver.takePersistableUriPermission( | |
folderUri, | |
Intent.FLAG_GRANT_READ_URI_PERMISSION | |
) | |
//use picked uri android | |
onFolderPickerResult?.invoke(folderUri) | |
} | |
} | |
//call to start folder picker in tree view | |
dirRequest.launch(null) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment