Deleting video files from gallery not working on Android 14

I am trying to make a function that deletes a selected video from a recycler view. After the confirmation in the confirmDeleteDialog I receive “Failed to delete video” , knowing that the same code was working fine in the same device before adding the “READ_MEDIA_VIDEO” and the “READ_MEDIA_VISUAL_USER_SELECTED” permissions in the manifest .
Below is the delete function, the function used to get the videos and the manifest file :

 binding.deleteVideoButton.setOnClickListener {
            //check this section there is something wrong with it
            val file = File(currentVideoUri.path.toString())
            if (file.exists() && !lock) {
                Utilities.moveViewUpAndBack(binding.deleteVideoButton)

                val confirmDeleteDialog = AlertDialog.Builder(this)
                    .setTitle(getString(R.string.delete_video))
                    .setMessage(getString(R.string.deletion_confirmation))
                    .setPositiveButton(getString(R.string.yes)) { _, _ ->
                        binding.progressBar.visibility = View.VISIBLE

                        CoroutineScope(Dispatchers.IO).launch {
                            val deleted = file.delete()
                            withContext(Dispatchers.Main) {
                                binding.progressBar.visibility = View.GONE
                                if (deleted) {
                                    val tempoVideos = Utilities.listVideos(applicationContext)
                                    val tempoThumbnails = Utilities.convertFilesToBitmaps(tempoVideos.take(5))
                                    val tempoUris = tempoVideos.map { Uri.fromFile(it) }
                                    if (tempoUris.isNotEmpty()) {
                                        currentVideoUri = tempoUris[0]
                                        preparePlayer(currentVideoUri)
                                    }
                                    adapter.updateThumbnails(tempoThumbnails, tempoUris)
                                    loadRemainingBitmaps(tempoVideos.drop(5))
                                } else {
                                    Toast.makeText(this@PreviewActivity,
                                        getString(R.string.failed_to_delete_video),
                                        Toast.LENGTH_SHORT).show()
                                }
                                //alertDialog.dismiss()
                            }
                        }
                    }
                    .setNegativeButton(getString(R.string.no), null)
                    .create()
                confirmDeleteDialog.show()
            } else {
                Toast.makeText(this, getString(R.string.file_not_found), Toast.LENGTH_SHORT).show()
            }
        }

listVideos() function

   fun listVideos(context: Context): List<File> {
            val videos = mutableListOf<File>()
            val projection = arrayOf(MediaStore.Video.Media._ID,
                MediaStore.Video.Media.DISPLAY_NAME,
                MediaStore.Video.Media.DATE_ADDED,
                MediaStore.Video.Media.DATA)

            val selection =
                "${MediaStore.Video.Media.DISPLAY_NAME} LIKE ? AND ${MediaStore.Video.Media.DISPLAY_NAME} NOT LIKE ? AND ${MediaStore.Video.Media.DISPLAY_NAME} LIKE ?"
            val selectionArgs = arrayOf("%camerago_%", "%.pending%", "%.mp4")

            val sortOrder = "${MediaStore.Video.Media.DATE_ADDED} DESC"

            val query = context.contentResolver.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                projection,
                selection,
                selectionArgs,
                sortOrder)
            query?.use { cursor ->
                val nameColumn = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME)
                val dataColumn = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)
                while (cursor.moveToNext()) {
                    val data = cursor.getString(dataColumn)
                    //Log.e("logo", "video name: $name")
                    videos.add(File(data))
                }
            }
            return videos
        }

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <uses-feature
        android:name="android.hardware.camera2"
        android:required="false" />
    <uses-feature android:name="android.hardware.camera.any" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
    <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />


    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >



        <!--implementation of a file provider in order to be able to share the video to other platforms-->
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="com.nerovero.camerago.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

        <!--check whether enabled attribute is necessary in the service or not   -->
        <service
            android:name=".VideoRecordingService"
            android:foregroundServiceType="camera|microphone"
            android:enabled="true"
            android:exported="false"
            />
        <activity
            android:name=".SettingsActivity"
            android:enabled="true"
            android:exported="false" />
        <activity
            android:name=".PreviewActivity"
            android:exported="true" >

        </activity>

        <activity
            android:name=".CameraActivity"
            android:exported="true"
            android:showWhenLocked="true"
            android:turnScreenOn="true"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>


</manifest>

I tried the contentResolver method but it does not work as well.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật