Reputation: 1095
In my app I created a file picker that returns a list of uris like the ones below:
[content://media/external/file/300725, content://media/external/file/299993, content://media/external/file/299986]
Is there any way to know if each of these files is an image or a video?
Upvotes: 1
Views: 2195
Reputation: 181
One way to do so is following this SO post
In short to find an image:
public static boolean isImageFile(String path) {
String mimeType = URLConnection.guessContentTypeFromName(path);
return mimeType != null && mimeType.startsWith("image"); }
To find a video:
public static boolean isVideoFile(String path) {
String mimeType = URLConnection.guessContentTypeFromName(path);
return mimeType != null && mimeType.startsWith("video");}
Upvotes: 3