简体   繁体   English

通过ContentResolver删除MediaLibrary文件引用:如何获取文件的ID?

[英]Deleting a MediaLibrary file reference via ContentResolver: how to get the file's id?

from this question I understand that if I want to remove a reference for a (video) file from the media library, I can do this: 这个问题中我了解到,如果我想从媒体库中删除对(视频)文件的引用,可以这样做:

Uri videoUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
Uri itemUri = ContentUris.withAppendedId(videoUri, mediaId);
getContentResolver().delete(itemUri, null, null);

what I miss is how to retrieve the mediaId . 我想念的是如何检索mediaId

For this file I have its path, filename, size, etc. 对于此文件,我具有其路径,文件名,大小等。

Any idea? 任何想法?

here the answer, look at the method getVideoIdFromFilePath : 在这里,请看方法getVideoIdFromFilePath

https://stackoverflow.com/a/11603899/1865860 https://stackoverflow.com/a/11603899/1865860

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过'ContentResolver'删除文件,而不是通过'file.delete()'删除它们 - Deleting files via a 'ContentResolver' as opposed to deleting them via 'file.delete()' ContentResolver —如何获取附件的文件路径 - ContentResolver — how to get file path of attachment ContentResolver - 如何从 Uri 获取文件名 - ContentResolver - how to get file name from Uri 如何使用 contentResolver 设置文件的编码类型? - How to set file's encode type using contentResolver? Android 10:contentResolver.delete() 没有从文件系统中删除文件 - Android 10: contentResolver.delete() is not deleting file from the file system 更新ContentResolver以获取更新的文件数 - Updating ContentResolver to get updated file count 通过QuickOffice中的ContentResolver的Android打开的.docx文件崩溃 - Android open .docx file via ContentResolver in QuickOffice crashes 如何获得对文件的引用 - How to get a reference to a file 如何在Android上使用ContentResolver.Query从SdCard获取mp3文件列表? - How To get mp3 file list from SdCard with ContentResolver.Query on Android? Fileobserver的onevent方法启动,但是在删除任何文件之前如何获取文件 - Fileobserver's onevent method fire but how can i get file before deleting any file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM