Skip to main content
Version: v3+

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​

PropertyTypeDescriptionAPI_LEVEL
totalnumberTotal Space in bytes2.0
freenumberAvailable Space in bytes2.0
appnumberSpace occupied by Mini Programs in bytes2.0
watchfacenumberSpace occupied by watchfaces in bytes2.0
musicnumberSpace occupied by musics in bytes2.0
systemnumberSpace occupied by system in bytes2.0

Callback​

Start from API_LEVEL 3.0 . Please refer to API_LEVEL.

TypeDescription
(diskInfo: Result) => voidCallback 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)
})