简体   繁体   中英

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 .

For this file I have its path, filename, size, etc.

Any idea?

here the answer, look at the method getVideoIdFromFilePath :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM