开发者

How to tell what's the MIME type according to the file?

开发者 https://www.devze.com 2023-01-29 20:07 出处:网络
Is there any elegant way (not just if (\"fileExt\".compareTo(\".mp3\")开发者_JAVA百科) {MIME_TYPE = \"audio/*\"}) to learn programatically the MIME type that should be put into an intent, with which I

Is there any elegant way (not just if ("fileExt".compareTo(".mp3")开发者_JAVA百科) {MIME_TYPE = "audio/*"}) to learn programatically the MIME type that should be put into an intent, with which I have to open the file?

Thanks!


well it does the same as your if statement but is slightly more elegant

Use the MimeTypeMap class

http://developer.android.com/reference/android/webkit/MimeTypeMap.html


You can use MediaStore to find the mime type:

http://developer.android.com/reference/android/provider/MediaStore.MediaColumns.html#MIME_TYPE

0

精彩评论

暂无评论...
验证码 换一张
取 消