Mark Lapasa
Mark Lapasa

Reputation: 1654

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

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.

Upvotes: 10

Views: 12108

Answers (2)

soKira
soKira

Reputation: 81

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 + "/";

Upvotes: 6

stuckless
stuckless

Reputation: 6545

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)

Upvotes: 4

Related Questions