getDataDiskInfo
Start from API_LEVEL
5.0. Please refer to API_LEVEL.
Gets the total, available, and used capacity of the data partition (data://) in bytes. This covers the whole data partition, not the current application's storage usage. Check isSuccess before reading the capacity fields.
info
permission code: data:os.device.info
Type
function getDataDiskInfo(): Result
Parameters
SuccessResult
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| isSuccess | true | The query succeeded | 5.0 |
| total | number | Total data partition capacity in bytes | 5.0 |
| free | number | Available data partition capacity in bytes | 5.0 |
| used | number | Used data partition capacity in bytes | 5.0 |
FailResult
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| isSuccess | false | The query failed; capacity fields are not included | 5.0 |
Result
| Type | Description |
|---|---|
SuccessResult|FailResult | undefined |
Example
import { getDataDiskInfo } from '@zos/device'
const result = getDataDiskInfo()
if (result.isSuccess) {
console.log(result.total, result.free, result.used)
}