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 目录下将被拒绝。
来自百度翻译: