[英]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.