Skip to content

Commit 7090f28

Browse files
committed
Add function to delete captured item
1 parent 2929a6b commit 7090f28

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

app/src/main/java/app/grapheneos/camera/CapturedItems.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ class CapturedItem(
6262
return dateString == other.dateString
6363
}
6464

65+
fun delete(context: Context) : Boolean {
66+
try {
67+
return if (uri.authority == MediaStore.AUTHORITY) {
68+
context.contentResolver.delete(uri, null, null) > 0
69+
} else {
70+
DocumentsContract.deleteDocument(context.contentResolver, uri)
71+
}
72+
} catch (e : Exception) {
73+
e.printStackTrace()
74+
return false
75+
}
76+
}
77+
6578
companion object {
6679
@JvmField
6780
val CREATOR = object : Parcelable.Creator<CapturedItem> {

0 commit comments

Comments
 (0)