问题描述
我有一个列出MediaStore所有视频的应用程序。 (我需要内部存储和外部存储)。
I have an application that lists all videos in MediaStore. (I need both internal storage and external storage).
基本上我有两个光标哪个查询MediaStore.Video.Media.EXTERNAL_CONTENT_URI和MediaStore.Video.Media.INTERNAL_CONTENT_URI。
Basically I have two cursors which query MediaStore.Video.Media.EXTERNAL_CONTENT_URI and MediaStore.Video.Media.INTERNAL_CONTENT_URI.
然后我用一个MergeCursor在一个CursorAdapter的一个ListView合并这些查询和显示。
Then I use a MergeCursor to merge these queries and display in a ListView with a CursorAdapter.
的事情是,有时我想删除的影片之一,但我需要的开放的内容进行此操作,因为我没有办法来确定选择的视频的存储空间。
The thing is that sometimes I want to delete one of the videos, but I need the "content Uri" for this operation because I don't have a way to determine the storage of the selected video.
我有视频的完整的文件路径和MediaStore的ID。
I have the full file path of the Video and the ID in MediaStore.
我怎样才能从文件的路径获得的内容URI/乌里?
How can I get the "content Uri" from the file path/Uri?
推荐答案
回答我的问题:)
实测容易且琐碎的方式找到的路径的存储(!):**
Found an easy and trivial(!) way to find the storage of the path:**
if(selectedVideoPath.indexOf(Environment.getExternalStorageDirectory().getPath()) == 0)
{
getContentResolver().delete(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
MediaStore.Video.Media._ID + "=" + videoId,
null);
}
else {
getContentResolver().delete(MediaStore.Video.Media.INTERNAL_CONTENT_URI,
MediaStore.Video.Media._ID + "=" + videoId,
null);
}
这篇关于从文件路径获取MediaStore内容乌里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!