user2532233 user2532233 - 1 year ago 73
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 Source

Easiest way is to check extensions I guess

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