Reputation: 820
What is the correct way to start a File Explorer by Intent in a specified directory?
Following code snippet works fine, except that it starts in the wrong directory.
The desired starting point would be at "selectedUri"
val selectedUri = Uri.parse(externalStorage.toString() + "DCIM/Camera/")
val intent= Intent(Intent.ACTION_GET_CONTENT).apply{
addCategory(Intent.CATEGORY_OPENABLE)
type = "image/*"
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
Upvotes: 0
Views: 119
Reputation: 47
you forgot to set the intent data
val selectedUri = Uri.parse(externalStorage.toString() + "DCIM/Camera/")
val intent= Intent(Intent.ACTION_GET_CONTENT).apply{
addCategory(Intent.CATEGORY_OPENABLE)
data = selectedUri
type = "image/*"
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
Upvotes: 1