-
Notifications
You must be signed in to change notification settings - Fork 0
Core Basic Features Format Storage
Mr.P edited this page Aug 29, 2026
·
1 revision
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.
Destructive operation
This action removes all device media and is not presented as recoverable by the SDK. Require explicit user confirmation before starting it.
- 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.
The completion callback reports whether the underlying delete-all request was accepted. It does not return refreshed media counts or storage information.
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");
}
});
}];
}- 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.
AIBuds SDK documentation · Full documentation · API Reference
- Introduction
- Getting Started
- Core Concepts
-
Core Features
- Basic Features
- Device Info
- Find Device
- Physical Operations
- Work Mode
- Work Status
- Wear Detection
- Volume Control
- Music Control
- TWS
- Equalizer
- ANC
- Audio
- Camera
- Remote Camera
- File Import
- Teleprompter
- Segment Navigation
- Live Streaming
- Device Applications
- OTA
- Camera OTA
- Service Auth
- AI Services
- Voice Assistant
- Logging
- Advanced Topics
- Releases
- Troubleshooting