MediaStore.Images.Media.getContentUri(String volumeName):Uri有什么作用?

Mar*_*asa 5 android

除此之外,Content Provider Media API的公共方法看起来非常简单.我不确定这是做什么或如何使用它.任何有关使用的见解将不胜感激.

小智 5

如源代码所示,您使用“内部”为INTERNAL_CONTENT_URI和“外部”为EXTERNAL_CONTENT_URI

    /**
     * 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");
Run Code Online (Sandbox Code Playgroud)

CONTENT_AUTHORITY_SLASH一样好content://media/

public static final String AUTHORITY = "media";

private static final String CONTENT_AUTHORITY_SLASH = "content://" + AUTHORITY + "/";
Run Code Online (Sandbox Code Playgroud)


stu*_*ess 4

我认为卷名是"external""internal"媒体的外部(SD卡)和内部位置。每个Media子容器都有这个。

它们还具有内部和外部URI 的静态常量,这可能比getContentUri(volumeName)

即,我认为(但我尚未证实)

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