getDiskInfo
Start from API_LEVEL
2.0. Please refer to API_LEVEL.
Gets device storage totals, available space, and usage by Mini Programs, watchfaces, music, and the system. Returns the result synchronously when called without arguments. Starting from API_LEVEL 3.0, pass a callback to query asynchronously; asynchronous queries are recommended.
Type
function getDiskInfo(): Result
function getDiskInfo(callback: Callback): void
Parameters
Result
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| total | number | Total Space in bytes | 2.0 |
| free | number | Available Space in bytes | 2.0 |
| app | number | Space occupied by Mini Programs in bytes | 2.0 |
| watchface | number | Space occupied by watchfaces in bytes | 2.0 |
| music | number | Space occupied by musics in bytes | 2.0 |
| system | number | Space occupied by system in bytes | 2.0 |
Callback
Start from API_LEVEL
3.0. Please refer to API_LEVEL.
| Type | Description |
|---|---|
(diskInfo: Result) => void | Callback receiving device storage information when the query completes; capacities are in bytes |
Example
import { getDiskInfo } from '@zos/device'
// Synchronous query
const diskInfo = getDiskInfo()
console.log(diskInfo.total, diskInfo.free)
// Asynchronous query (API_LEVEL 3.0+)
getDiskInfo((diskInfo) => {
console.log(diskInfo.total, diskInfo.free)
console.log(diskInfo.app, diskInfo.watchface, diskInfo.music, diskInfo.system)
})