StorageManager.AllocateBytes 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| AllocateBytes(FileDescriptor, Int64) |
在指定的開啟檔案中分配應用程式所需的位元組數。 |
| AllocateBytes(UUID, Int64) |
在指定的儲存區分配應用程式所需的位元組數。 |
AllocateBytes(FileDescriptor, Int64)
在指定的開啟檔案中分配應用程式所需的位元組數。
[Android.Runtime.Register("allocateBytes", "(Ljava/io/FileDescriptor;J)V", "GetAllocateBytes_Ljava_io_FileDescriptor_JHandler", ApiSince=26)]
public virtual void AllocateBytes(Java.IO.FileDescriptor? fd, long bytes);
[<Android.Runtime.Register("allocateBytes", "(Ljava/io/FileDescriptor;J)V", "GetAllocateBytes_Ljava_io_FileDescriptor_JHandler", ApiSince=26)>]
abstract member AllocateBytes : Java.IO.FileDescriptor * int64 -> unit
override this.AllocateBytes : Java.IO.FileDescriptor * int64 -> unit
參數
你想分配磁碟空間的開啟檔案。
- bytes
- Int64
分配的位元組數。 這是開啟檔案的期望最終大小。 若開啟檔案大小小於請求大小,則可擴充且不修改現有內容。 若開啟檔案大小超過請求大小,則會被截斷。
- 屬性
備註
在指定的開啟檔案中分配應用程式所需的位元組數。 這會導致系統刪除任何快取檔案以滿足你的請求。
嘗試分配超出回 #getAllocatableBytes(UUID) 傳值的磁碟空間將失敗。
此方法保證已分配位元組給已開啟的檔案,否則若無法快速分配,則會拋出。 快速分配通常僅支援於私人應用程式資料目錄,以及模擬的共享/外部儲存裝置。
如果你是逐步分配無限儲存空間(例如錄製影片時),應該避免每 60 秒呼叫超過一次。
Java 文件 android.os.storage.StorageManager.allocateBytes(java.io.FileDescriptor, long)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
適用於
AllocateBytes(UUID, Int64)
在指定的儲存區分配應用程式所需的位元組數。
[Android.Runtime.Register("allocateBytes", "(Ljava/util/UUID;J)V", "GetAllocateBytes_Ljava_util_UUID_JHandler", ApiSince=26)]
public virtual void AllocateBytes(Java.Util.UUID storageUuid, long bytes);
[<Android.Runtime.Register("allocateBytes", "(Ljava/util/UUID;J)V", "GetAllocateBytes_Ljava_util_UUID_JHandler", ApiSince=26)>]
abstract member AllocateBytes : Java.Util.UUID * int64 -> unit
override this.AllocateBytes : Java.Util.UUID * int64 -> unit
參數
- storageUuid
- UUID
你想分配磁碟空間的儲存磁碟區的 UUID。 特定路徑的 UUID 可用 取得 #getUuidForPath(File)。
- bytes
- Int64
分配的位元組數。
- 屬性
備註
在指定的儲存區分配應用程式所需的位元組數。 這會導致系統刪除任何快取檔案以滿足你的請求。
嘗試分配超出回 #getAllocatableBytes(UUID) 傳值的磁碟空間將失敗。
由於多個應用程式可以同時執行,此方法可能會受到競賽條件的影響。 如果可能,考慮使用 #allocateBytes(FileDescriptor, long) 能保證有位元組分配給已開啟檔案的
如果你是逐步分配無限儲存空間(例如錄製影片時),應該避免每 60 秒呼叫超過一次。
Java 文件 android.os.storage.StorageManager.allocateBytes(java.util.UUID, long)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。