How I can get the mime type of a file having its Uri?

前端 未结 4 1330
南旧
南旧 2020-12-12 12:22

I have a List of Uris obtained with the Gallery and the Camera. These Uris are like this: content://media/external/images/media/94. How I can get its mime type?

4条回答
  •  长情又很酷
    2020-12-12 12:55

    Instead of this:

    String type = mime.getExtensionFromMimeType(cR.getType(uri));
    

    Do this:

    String type = cR.getType(uri);
    

    And you will get this: image/jpeg.

提交回复
热议问题