0

Uri when select any image or video -> "content://media/external/file/34"

1 Answers1

1

Please try with below line of code

Uri selectedUri;
String fileextension = MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString());
String mimetype= MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileextension);

If(mimetype=="image/jpeg")
Dharman
  • 30,962
  • 25
  • 85
  • 135
gpuser
  • 1,143
  • 1
  • 9
  • 6
  • I have Uri in arraylist, so how to apply this solution? – Monali0521 Jul 19 '21 at 12:57
  • If you are getting the list of video/image in this way using the ccontent resolver and cursor then please try below way private val PROJECTION = arrayOf(MediaStore.MediaColumns.MIME_TYPE) String pictureType = cursor.getString(cursor.getColumnIndexOrThrow(PROJECTION[0])) IF NOT then try to check when you added or get in list for every item in list – gpuser Jul 19 '21 at 13:09
  • Thanks. I will apply and let you know if it is working or not. – Monali0521 Jul 20 '21 at 04:12