user2532233 user2532233 - 1 month ago 7
Android Question

Check if a file is an image or a video

Is there a way to check if the file I'm loading as a URI is a image or a video in android? I'm trying to dynamically loaded both images and videos into fragments for a list/detail view and need to tell them apart.

Answer

Easiest way is to check extensions I guess

if ( file.toString().endsWith(".jpg") {
//photo
} else if (file.toString().endsWith(".3gp")) {
//video
}