Getting the Type of File as String

1 vote · 2 comments

Get the Type of a File.

raw ·
copy
· download
ContentResolver cR = context.getContentResolver(); MimeTypeMap mime = MimeTypeMap.getSingleton(); String type = mime.getExtensionFromMimeType(cR.getType(uri));
Add a comment

2 Comments

Interesting,

I was so lucky to find this post there is no explanation for this code , and and googled it for"Getting the Type of File as String"

Thanks for writing about it

Reply · Aug. 20, 2009, 8:13 p.m.
  1. ContentResolver cR = context.getContentResolver();
  2. MimeTypeMap mime = MimeTypeMap.getSingleton();
  3. String type = mime.getExtensionFromMimeType(cR.getType(uri));

great piece of code, it's truely handy

Reply · Aug. 21, 2009, 12:07 a.m.