Get extension from path in android
For find extension from a given path you can use any one from given solution:
Method 1: Get extension from string path
String path = "/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20190125-WA0010.mp4";
String extension = path.substring(path.lastIndexOf("."));
Method 2: Get an extension from the file
So in your case, it should be something like that
String path = "/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20190125-WA0010.mp4";
File file = new File(path);
String extension = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf("."));
Method 3:
You can use Utility Library of Android FilenameUtils.getExtension from Apache Commons IO-
String extension = FilenameUtils.getExtension("/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20190125-WA0010.mp4");
Keywords: