I have an application that lists all videos in MediaStore. (I need both internal storage and external storage).
Basically I have two cursors which query MediaStore.Video.Media.EXTERNAL_CONTENT_URI and MediaStore.Video.Media.INTERNAL_CONTENT_URI.
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.
I have the full file path of the Video and the ID in MediaStore.
How can I get the "content Uri" from the file path/Uri?
Best Answer
To answer the question in the title:
I have to get the path from URIs and get the URI from paths in my app. The former:
The latter (which I do for videos, but can also be used for Audio or Files or other types of stored content by substituting MediaStore.Audio (etc) for MediaStore.Video):
Basically, the
DATA
column ofMediaStore
(or whichever sub-section of it you're querying) stores the file path, so you use that info to look it up.