MediaStore的RELATIVE_PATH的变量的定义

Android Q的MediaStore类中新增了变量RELATIVE_PATH的定义如下:

String android.provider.MediaStore.MediaColumns.RELATIVE_PATH : "relative_path"

        /**
         * Relative path of this media item within the storage device where it
         * is persisted. For example, an item stored at
         * {@code /storage/0000-0000/DCIM/Vacation/IMG1024.JPG} would have a
         * path of {@code DCIM/Vacation/}.
         * <p>
         * This value should only be used for organizational purposes, and you
         * should not attempt to construct or access a raw filesystem path using
         * this value. If you need to open a media item, use an API like
         * {@link ContentResolver#openFileDescriptor(Uri, String)}.
         * <p>
         * When this value is set to {@code NULL} during an
         * {@link ContentResolver#insert} operation, the newly created item will
         * be placed in a relevant default location based on the type of media
         * being inserted. For example, a {@code image/jpeg} item will be placed
         * under {@link Environment#DIRECTORY_PICTURES}.
         * <p>
         * You can modify this column during an {@link ContentResolver#update}
         * call, which will move the underlying file on disk.
         * <p>
         * In both cases above, content must be placed under a top-level
         * directory that is relevant to the media type. For example, attempting
         * to place a {@code audio/mpeg} file under
         * {@link Environment#DIRECTORY_PICTURES} will be rejected.
         */
        @Column(Cursor.FIELD_TYPE_STRING)
        public static final String RELATIVE_PATH = "relative_path";

注释翻译如下:

原文:

Relative path of this media item within the storage device where it is persisted. For example, an item stored at /storage/0000-0000/DCIM/Vacation/IMG1024.JPG would have a path of DCIM/Vacation.

This value should only be used for organizational purposes, and you should not attempt to construct or access a raw filesystem path using this value. If you need to open a media item, use an API like ContentResolver#openFileDescriptor(Uri, String).

When this value is set to NULL during an ContentResolver#insert operation, the newly created item will be placed in a relevant default location based on the type of media being inserted. For example, a image/jpeg item will be placed under Environment#DIRECTORY_PICTURES.

You can modify this column during an ContentResolver#update call, which will move the underlying file on disk.

In both cases above, content must be placed under a top-level directory that is relevant to the media type. For example, attempting to place a audio/mpeg file under Environment#DIRECTORY_PICTURES will be rejected.

译文:

此媒体项在存储设备中持久化的相对路径。例如,存储在/storage/0000-0000/DCIM/Vacation/IMG1024.JPG中的项的路径为DCIM/Vacation。

此值应仅用于组织目的,不应尝试使用此值构造或访问原始文件系统路径。如果需要打开媒体项,请使用类似于ContentResolver#openFileDescriptor(Uri,String)的API。

如果在ContentResolver插入操作中将此值设置为空,则新创建的项将根据插入的媒体类型放置在相关的默认位置。例如,图像/jpeg项目将放置在环境目录图片下。

您可以在ContentResolver#update调用期间修改此列,该调用将移动磁盘上的基础文件。

在上述两种情况下,内容都必须放在与媒体类型相关的顶级目录下。例如,尝试将audio/mpeg文件放置在 Environment#DIRECTORY_PICTURES 目录下将被拒绝。

来自百度翻译:

https://fanyi.baidu.com/#en/zh/Relative%20path%20of%20this%20media%20item%20within%20the%20storage%20device%20where%20it%20is%20persisted.%20For%20example%2C%20an%20item%20stored%20at%20%2Fstorage%2F0000-0000%2FDCIM%2FVacation%2FIMG1024.JPG%20would%20have%20a%20path%20of%20DCIM%2FVacation.%0A%0AThis%20value%20should%20only%20be%20used%20for%20organizational%20purposes%2C%20and%20you%20should%20not%20attempt%20to%20construct%20or%20access%20a%20raw%20filesystem%20path%20using%20this%20value.%20If%20you%20need%20to%20open%20a%20media%20item%2C%20use%20an%20API%20like%20ContentResolver%23openFileDescriptor(Uri%2C%20String).%0A%0AWhen%20this%20value%20is%20set%20to%20NULL%20during%20an%20ContentResolver%23insert%20operation%2C%20the%20newly%20created%20item%20will%20be%20placed%20in%20a%20relevant%20default%20location%20based%20on%20the%20type%20of%20media%20being%20inserted.%20For%20example%2C%20a%20image%2Fjpeg%20item%20will%20be%20placed%20under%20Environment%23DIRECTORY_PICTURES.%0A%0AYou%20can%20modify%20this%20column%20during%20an%20ContentResolver%23update%20call%2C%20which%20will%20move%20the%20underlying%20file%20on%20disk.%0A%0AIn%20both%20cases%20above%2C%20content%20must%20be%20placed%20under%20a%20top-level%20directory%20that%20is%20relevant%20to%20the%20media%20type.%20For%20example%2C%20attempting%20to%20place%20a%20audio%2Fmpeg%20file%20under%20Environment%23DIRECTORY_PICTURES%20will%20be%20rejected.

发布了270 篇原创文章 · 获赞 274 · 访问量 377万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览