StorageManager.AllocateBytes Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AllocateBytes(FileDescriptor, Int64) |
Allocate the requested number of bytes for your application to use in the given open file. |
AllocateBytes(UUID, Int64) |
Allocate the requested number of bytes for your application to use on the given storage volume. |
AllocateBytes(FileDescriptor, Int64)
Allocate the requested number of bytes for your application to use in the given open file.
[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
Parameters
the open file that you'd like to allocate disk space for.
- bytes
- Int64
the number of bytes to allocate. This is the desired final size of the open file. If the open file is smaller than this requested size, it will be extended without modifying any existing contents. If the open file is larger than this requested size, it will be truncated.
- Attributes
Remarks
Allocate the requested number of bytes for your application to use in the given open file. This will cause the system to delete any cached files necessary to satisfy your request.
Attempts to allocate disk space beyond the value returned by #getAllocatableBytes(UUID)
will fail.
This method guarantees that bytes have been allocated to the opened file, otherwise it will throw if fast allocation is not possible. Fast allocation is typically only supported in private app data directories, and on shared/external storage devices which are emulated.
If you're progressively allocating an unbounded amount of storage space (such as when recording a video) you should avoid calling this method more than once every 60 seconds.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
AllocateBytes(UUID, Int64)
Allocate the requested number of bytes for your application to use on the given storage volume.
[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
Parameters
- storageUuid
- UUID
the UUID of the storage volume where you'd like to
allocate disk space. The UUID for a specific path can be
obtained using #getUuidForPath(File)
.
- bytes
- Int64
the number of bytes to allocate.
- Attributes
Remarks
Allocate the requested number of bytes for your application to use on the given storage volume. This will cause the system to delete any cached files necessary to satisfy your request.
Attempts to allocate disk space beyond the value returned by #getAllocatableBytes(UUID)
will fail.
Since multiple apps can be running simultaneously, this method may be subject to race conditions. If possible, consider using #allocateBytes(FileDescriptor, long)
which will guarantee that bytes are allocated to an opened file.
If you're progressively allocating an unbounded amount of storage space (such as when recording a video) you should avoid calling this method more than once every 60 seconds.
Java documentation for android.os.storage.StorageManager.allocateBytes(java.util.UUID, long)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.