Hi,
I am using the following code:
String type = null;
if (fileUrl != null) {
try {
URL url = new URL("file:/"+fileUrl);
URLConnection urlConnection = null;
urlConnection = url.openConnection();
type = urlConnection.getContentType();
} catch (MalformedURLException e) {
Log.e(Constants.TAG, "Error when getting MIME
type for " +
fileUrl, e);
} catch (IOException e) {
Log.e(Constants.TAG, "Error when getting MIME
type for " +
fileUrl, e);
}
}
return type;
It doesn't seem to be much efficient performance wise.
I tried that one here, but it didn't work on the emulator (haven't
tried it on any device though).
FileNameMap fileNameMap = URLConnection.getFileNameMap();
String type = fileNameMap.getContentTypeFor("file:/"+fileUrl);
Do you guy have any other suggestions?
Regards
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
To unsubscribe, reply using "remove me" as the subject.