Java tutorial
//package com.java2s; import android.net.Uri; import android.text.TextUtils; public class Main { public static final String EXT_DASH = ".mpd"; public static final String EXT_SS = ".ism"; public static final String EXT_HLS = ".m3u8"; public static final int TYPE_DASH = 0; public static final int TYPE_SS = 1; public static final int TYPE_HLS = 2; public static final int TYPE_OTHER = 3; public static int inferContentType(Uri uri, String fileExtension) { String lastPathSegment = !TextUtils.isEmpty(fileExtension) ? "." + fileExtension : uri.getLastPathSegment(); if (lastPathSegment == null) { return TYPE_OTHER; } else if (lastPathSegment.endsWith(EXT_DASH)) { return TYPE_DASH; } else if (lastPathSegment.endsWith(EXT_SS)) { return TYPE_SS; } else if (lastPathSegment.endsWith(EXT_HLS)) { return TYPE_HLS; } else { return TYPE_OTHER; } } }