Returns true if uri is a media uri. - Android android.provider

Android examples for android.provider:MediaStore

Description

Returns true if uri is a media uri.

Demo Code


//package com.java2s;
import android.provider.MediaStore.Audio;
import android.provider.MediaStore.Video;

public class Main {
    /**/* ww  w  .j a v a2 s .  c o m*/
     * Returns true if uri is a media uri.
     * 
     * @param uri
     * @return
     */
    public static boolean isMediaUri(String uri) {
        if (uri.startsWith(Audio.Media.INTERNAL_CONTENT_URI.toString())
                || uri.startsWith(Audio.Media.EXTERNAL_CONTENT_URI
                        .toString())
                || uri.startsWith(Video.Media.INTERNAL_CONTENT_URI
                        .toString())
                || uri.startsWith(Video.Media.EXTERNAL_CONTENT_URI
                        .toString())) {
            return true;
        } else {
            return false;
        }
    }
}

Related Tutorials