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 目錄下將被拒絕。
來自百度翻譯: