Format Media Storage
Use formatStorage to delete every photo, video, and audio recording stored on a connected device. Despite its name, this API delegates to the existing delete-all-media operation; it does not issue a separate filesystem-format command.
:::danger Destructive operation
This action removes all device media and is not presented as recoverable by the SDK. Require explicit user confirmation before starting it.
:::
Prerequisites
- Wait until the device is connected and ready.
- Stop recording and finish or cancel active media imports.
- Disable repeated submission while the operation is in progress.
Implement with AI Assistance
Build with AI
Implement this workflow with AI
Use the official Implement AIBuds Storage Formatting skill to adapt this workflow to your app.
Read and follow https://docs-aibuds.github.io/skills/implement-aibuds-format-storage. Use it to implement Implement AIBuds Storage Formatting in this iOS project and verify the result.API Behavior
The completion callback reports whether the underlying delete-all request was accepted. It does not return refreshed media counts or storage information.
Usage Example
- Swift
- Objective-C
import AIBuds
func formatMediaStorage(on device: DeviceConvertible) {
guard let device = device as? DeviceCommonAPI else {
print("This device does not support common operations")
return
}
device.formatStorage { success, error in
DispatchQueue.main.async {
if success {
print("All device media was deleted")
} else {
print("Delete failed: \(error?.localizedDescription ?? "Unknown error")")
}
}
}
}#import <AIBuds/AIBuds-Swift.h>
- (void)formatMediaStorageOnDevice:(id<AIBudsDeviceConvertible>)device {
if (![device conformsToProtocol:@protocol(AIBudsDeviceCommonAPI)]) {
NSLog(@"This device does not support common operations");
return;
}
[(id<AIBudsDeviceCommonAPI>)device
formatStorageWithCompletion:^(BOOL success, NSError *_Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (success) {
NSLog(@"All device media was deleted");
} else {
NSLog(@"Delete failed: %@",
error.localizedDescription ?: @"Unknown error");
}
});
}];
}Result Handling
- On success, refresh the UI with Query Media Count and Query Storage Information.
- On failure, preserve the returned error for diagnostics and allow retry only after the current request finishes.
- If the device disconnects before completion, treat the result as indeterminate until device state is queried again.