Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.net.Uri;

import android.webkit.MimeTypeMap;

import java.io.File;

public class Main {
    public static boolean isPicture(File file) {

        Uri uri = Uri.fromFile(file);
        String type = MimeTypeMap.getSingleton()
                .getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString()));

        if (type == null)
            return false;
        else
            return (type.toLowerCase().startsWith("image/"));
    }
}