Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does MediaStore.Images.Media.getContentUri(String volumeName):Uri do?

Tags:

android

The public methods for the Content Provider Media API look pretty straight forward to me except for this one. I'm not sure what this does or how to use it. Any insight on usage would be appreciated.

like image 611
Mark Lapasa Avatar asked Jan 20 '12 20:01

Mark Lapasa


2 Answers

You use "internal" for INTERNAL_CONTENT_URI and "external" for EXTERNAL_CONTENT_URI, as revealed by the source code:

    /**
     * Get the content:// style URI for the image media table on the
     * given volume.
     *
     * @param volumeName the name of the volume to get the URI for
     * @return the URI to the image media table on the given volume
     */
    public static Uri getContentUri(String volumeName) {
        return Uri.parse(CONTENT_AUTHORITY_SLASH + volumeName +
                "/images/media");
    }

    /**
     * The content:// style URI for the internal storage.
     */
    public static final Uri INTERNAL_CONTENT_URI =
            getContentUri("internal");

    /**
     * The content:// style URI for the "primary" external storage
     * volume.
     */
    public static final Uri EXTERNAL_CONTENT_URI =
            getContentUri("external");

CONTENT_AUTHORITY_SLASH is as good as content://media/.

public static final String AUTHORITY = "media";

private static final String CONTENT_AUTHORITY_SLASH = "content://" + AUTHORITY + "/";
like image 155
soKira Avatar answered Oct 02 '22 22:10

soKira


I think the volume names are "external" and "internal" to refer to external (sdcard) and internal locations for the media. Each of the Media sub containers has this.

They also have static constant for the Internal and External URIs as well, which is probably preferred to use over the getContentUri(volumeName)

ie, I would think (but I haven't verified) that

MediaStore.Images.Media.getContentUri("external").equals(MediaStore.Images.Media.EXTERNAL_CONTENT_URI)

like image 40
stuckless Avatar answered Oct 02 '22 23:10

stuckless