Last active
November 28, 2021 09:22
-
-
Save fercarcedo/fc1a2452d47a61a6bfdb759ed6e62ffa to your computer and use it in GitHub Desktop.
Delete images Scoped Storage
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
private fun deleteImages(uris: List<Uri>) { | |
val pendingIntent = MediaStore.createDeleteRequest(contentResolver, uris.filter { | |
checkUriPermission(it, Binder.getCallingPid(), Binder.getCallingUid(), Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != PackageManager.PERMISSION_GRANTED | |
}) | |
startIntentSenderForResult(pendingIntent.intentSender, REQ_CODE, null, 0, 0, 0) | |
} | |
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
if (requestCode == REQ_CODE && resultCode == Activity.RESULT_OK) { | |
// Image deleted successfully | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment