應(yīng)用空間統(tǒng)計(jì)

2024-01-23 16:33 更新

該模塊提供空間查詢相關(guān)的常用功能:包括對(duì)內(nèi)外卡的空間查詢,對(duì)應(yīng)用分類數(shù)據(jù)統(tǒng)計(jì)的查詢,對(duì)應(yīng)用數(shù)據(jù)的查詢等。

說明

本模塊首批接口從API version 8開始支持。后續(xù)版本的新增接口,采用上角標(biāo)單獨(dú)標(biāo)記接口的起始版本。

導(dǎo)入模塊

  1. import storageStatistics from "@ohos.file.storageStatistics";

storageStatistics.getCurrentBundleStats9+

getCurrentBundleStats(): Promise<BundleStats>

第三方應(yīng)用異步獲取當(dāng)前應(yīng)用存儲(chǔ)空間大?。▎挝粸锽yte),以promise方式返回。

系統(tǒng)能力:SystemCapability.FileManagement.StorageService.SpatialStatistics

返回值:

類型

說明

Promise<Bundlestats>

返回指定卷上的應(yīng)用存空間大?。▎挝粸锽yte)

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見文件管理錯(cuò)誤碼

錯(cuò)誤碼ID

錯(cuò)誤信息

401

The input parameter is invalid.

13600001

IPC error.

13900032

Unknown error.

示例:

  1. let bundleStats = storageStatistics.getCurrentBundleStats();
  2. console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));

storageStatistics.getCurrentBundleStats9+

getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void

第三方應(yīng)用異步獲取當(dāng)前應(yīng)用存儲(chǔ)空間大?。▎挝粸锽yte),以callback方式返回。

系統(tǒng)能力:SystemCapability.FileManagement.StorageService.SpatialStatistics

參數(shù):

參數(shù)名

類型

必填

說明

callback

AsyncCallback<BundleStats>

獲取指定卷上的應(yīng)用存儲(chǔ)空間大小之后的回調(diào)

錯(cuò)誤碼:

以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見文件管理錯(cuò)誤碼

錯(cuò)誤碼ID

錯(cuò)誤信息

401

The input parameter is invalid.

13600001

IPC error.

13900032

Unknown error.

示例:

  1. storageStatistics.getCurrentBundleStats(function(error, bundleStats){
  2. // do something
  3. console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
  4. });

BundleStats9+

系統(tǒng)能力:以下各項(xiàng)對(duì)應(yīng)的系統(tǒng)能力均為SystemCapability.FileManagement.StorageService.SpatialStatistics

名稱

類型

可讀

可寫

說明

appSize

number

app數(shù)據(jù)大?。▎挝粸锽yte)

cacheSize

number

緩存數(shù)據(jù)大小(單位為Byte)

dataSize

number

應(yīng)用總數(shù)據(jù)大?。▎挝粸锽yte)

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)