I found a way to get the mime type of a content uri but nothing worked for other kind of uri's such as uri's of the form 'file://.....' .
To get the mime type of content uri's -
ContentResolver cr = this.getContentResolver();
String mime = cr.getType(YOUR_CONTENT_URI);
This works only for content uri's . So for other uri's I am using MimeTypeMap to infer their mime type's from the file extension .