• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.file.storageStatistics (Application Storage Statistics) (System API)
2<!--Kit: Core File Kit-->
3<!--Subsystem: FileManagement-->
4<!--Owner: @wang_zhangjun; @zhuangzhuang-->
5<!--Designer: @wang_zhangjun; @zhuangzhuang; @renguang1116-->
6<!--Tester: @liuhonggang123; @yue-ye2; @juxiaopang-->
7<!--Adviser: @foryourself-->
8
9The **storageStatistics** module provides APIs for obtaining storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data.
10
11> **NOTE**
12>
13> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
14> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.file.storageStatistics](js-apis-file-storage-statistics.md).
15
16## Modules to Import
17
18```ts
19import storageStatistics from "@ohos.file.storageStatistics";
20```
21
22## storageStatistics.getTotalSizeOfVolume
23
24getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
25
26Obtains the total space of a volume in an external storage device, in bytes. This API uses a promise to return the result.
27
28**Required permissions**: ohos.permission.STORAGE_MANAGER
29
30**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
31
32**System API**: This is a system API.
33
34**Parameters**
35
36  | Name    | Type  | Mandatory| Description|
37  | ---------- | ------ | ---- | ---- |
38  | volumeUuid | string | Yes  | UUID of the volume.|
39
40**Return value**
41
42  | Type                 | Description            |
43  | --------------------- | ---------------- |
44  | Promise&lt;number&gt; | Promise used to return the total volume space (in bytes) obtained.|
45
46**Error codes**
47
48For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
49
50| ID| Error Message|
51| -------- | -------- |
52| 201 | Permission verification failed. |
53| 202 | The caller is not a system application. |
54| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
55| 13600001 | IPC error. |
56| 13600008 | No such object. |
57| 13900042 | Unknown error. |
58
59**Example**
60
61  ```ts
62  import volumemanager from "@ohos.file.volumeManager";
63  import { BusinessError } from '@ohos.base';
64  volumemanager.getAllVolumes().then((volumes: Array<volumemanager.Volume>) => {
65    let uuid: string = volumes[0].uuid;
66    storageStatistics.getTotalSizeOfVolume(uuid).then((number: number) => {
67      console.info("getTotalSizeOfVolume successfully:" + number);
68    }).catch((err: BusinessError) => {
69      console.error("getTotalSizeOfVolume failed with error:" + JSON.stringify(err));
70    });
71  }).catch((err: BusinessError) => {
72    console.error("getAllVolumes failed with error:" + JSON.stringify(err));
73  });
74  ```
75
76## storageStatistics.getTotalSizeOfVolume
77
78getTotalSizeOfVolume(volumeUuid: string, callback: AsyncCallback&lt;number&gt;): void
79
80Obtains the total space of a volume in an external storage device, in bytes. This API uses an asynchronous callback to return the result.
81
82**Required permissions**: ohos.permission.STORAGE_MANAGER
83
84**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
85
86**System API**: This is a system API.
87
88**Parameters**
89
90  | Name    | Type                                | Mandatory| Description                      |
91  | ---------- | ------------------------------------ | ---- | -------------------------- |
92  | volumeUuid | string                               | Yes  | UUID of the volume.                      |
93  | callback   | AsyncCallback&lt;number&gt;          | Yes  | Callback used to return the total volume space obtained.|
94
95**Error codes**
96
97For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
98
99| ID| Error Message|
100| -------- | -------- |
101| 201 | Permission verification failed. |
102| 202 | The caller is not a system application. |
103| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
104| 13600001 | IPC error. |
105| 13600008 | No such object. |
106| 13900042 | Unknown error. |
107
108**Example**
109
110  ```ts
111  import volumemanager from "@ohos.file.volumeManager";
112  import { BusinessError } from '@ohos.base';
113  volumemanager.getAllVolumes().then((volumes: Array<volumemanager.Volume>) => {
114    let uuid: string = volumes[0].uuid;
115    storageStatistics.getTotalSizeOfVolume(uuid, (error: BusinessError, number: number) => {
116      if (error) {
117        console.error("getTotalSizeOfVolume failed with error:" + JSON.stringify(error));
118      } else {
119        // Do something.
120        console.info("getTotalSizeOfVolume successfully:" + number);
121      }
122    });
123  }).catch((err: BusinessError) => {
124    console.error("getAllVolumes failed with error:" + JSON.stringify(err));
125  });
126  ```
127
128## storageStatistics.getFreeSizeOfVolume
129
130getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
131
132Obtains the available space of a volume in an external storage device, in bytes. This API uses a promise to return the result.
133
134**Required permissions**: ohos.permission.STORAGE_MANAGER
135
136**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
137
138**System API**: This is a system API.
139
140**Parameters**
141
142  | Name    | Type  | Mandatory| Description|
143  | ---------- | ------ | ---- | ---- |
144  | volumeUuid | string | Yes  | UUID of the volume.|
145
146**Return value**
147
148  | Type                 | Description              |
149  | --------------------- | ------------------ |
150  | Promise&lt;number&gt; | Promise used to return the available volume space (in bytes) obtained.|
151
152**Error codes**
153
154For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
155
156| ID| Error Message|
157| -------- | -------- |
158| 201 | Permission verification failed. |
159| 202 | The caller is not a system application. |
160| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
161| 13600001 | IPC error. |
162| 13600008 | No such object. |
163| 13900042 | Unknown error. |
164
165**Example**
166
167  ```ts
168  import volumemanager from "@ohos.file.volumeManager";
169  import { BusinessError } from '@ohos.base';
170  volumemanager.getAllVolumes().then((volumes: Array<volumemanager.Volume>) => {
171    let uuid: string = volumes[0].uuid;
172    storageStatistics.getFreeSizeOfVolume(uuid).then((number: number) => {
173      console.info("getFreeSizeOfVolume successfully:" + number);
174    }).catch((err: BusinessError) => {
175      console.error("getFreeSizeOfVolume failed with error:" + JSON.stringify(err));
176    });
177  }).catch((err: BusinessError) => {
178    console.error("getAllVolumes failed with error:" + JSON.stringify(err));
179  });
180  ```
181
182## storageStatistics.getFreeSizeOfVolume
183
184getFreeSizeOfVolume(volumeUuid: string, callback: AsyncCallback&lt;number&gt;): void
185
186Obtains the available space of a volume in an external storage device, in bytes. This API uses an asynchronous callback to return the result.
187
188**Required permissions**: ohos.permission.STORAGE_MANAGER
189
190**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
191
192**System API**: This is a system API.
193
194**Parameters**
195
196  | Name    | Type                                | Mandatory| Description                        |
197  | ---------- | ------------------------------------ | ---- | ---------------------------- |
198  | volumeUuid | string                               | Yes  | UUID of the volume.                        |
199  | callback   | AsyncCallback&lt;number&gt;          | Yes  | Callback used to return the available volume space obtained.|
200
201**Error codes**
202
203For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
204
205| ID| Error Message|
206| -------- | -------- |
207| 201 | Permission verification failed. |
208| 202 | The caller is not a system application. |
209| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
210| 13600001 | IPC error. |
211| 13600008 | No such object. |
212| 13900042 | Unknown error. |
213
214**Example**
215
216  ```ts
217  import volumemanager from "@ohos.file.volumeManager";
218  import { BusinessError } from '@ohos.base';
219  volumemanager.getAllVolumes().then((volumes: Array<volumemanager.Volume>) => {
220    let uuid: string = volumes[0].uuid;
221    storageStatistics.getFreeSizeOfVolume(uuid, (error: BusinessError, number: number) => {
222      if (error) {
223        console.error("getFreeSizeOfVolume failed with error:" + JSON.stringify(error));
224      } else {
225        // Do something.
226        console.info("getFreeSizeOfVolume successfully: " + number);
227      }
228    });
229  }).catch((err: BusinessError) => {
230    console.error("getAllVolumes failed with error:" + JSON.stringify(err));
231  });
232  ```
233
234## storageStatistics.getBundleStats<sup>9+</sup>
235
236getBundleStats(packageName: string, index?: number): Promise&lt;BundleStats&gt;
237
238Obtains the storage space of an application, in bytes. This API uses a promise to return the result.
239
240**Required permissions**: ohos.permission.STORAGE_MANAGER
241
242**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
243
244**System API**: This is a system API.
245
246**Parameters**
247
248  | Name     | Type  | Mandatory| Description    |
249  | ----------- | ------ | ---- | -------- |
250  | packageName | string | Yes  | Package name of the application.|
251  | index<sup>12+</sup> | number | No  | Index of an application clone. The default value is **0**, which indicates the application itself. When an application clone is created, an index is assigned from 1 sequentially to **appIndex** of [BundleResourceInfo](../apis-ability-kit/js-apis-bundleManager-BundleResourceInfo-sys.md#bundleresourceinfo). The index can be obtained by [getBundleResourceInfo](../apis-ability-kit/js-apis-bundleResourceManager-sys.md#bundleresourcemanagergetbundleresourceinfo12).|
252
253**Return value**
254
255  | Type                                      | Description                      |
256  | ------------------------------------------ | -------------------------- |
257  | Promise&lt;[Bundlestats](js-apis-file-storage-statistics.md#bundlestats9)&gt; | Promise used to return the application storage space (in bytes) obtained.|
258
259**Error codes**
260
261For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
262
263| ID| Error Message|
264| -------- | -------- |
265| 201 | Permission verification failed. |
266| 202 | The caller is not a system application. |
267| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
268| 13600001 | IPC error. |
269| 13600008 | No such object. |
270| 13900042 | Unknown error. |
271
272**Example**
273
274  ```ts
275  import bundleResourceManager from '@ohos.bundle.bundleResourceManager';
276  import storageStatistics from "@ohos.file.storageStatistics";
277  import { BusinessError } from '@ohos.base';
278  import { hilog } from '@kit.PerformanceAnalysisKit';
279
280  let bundleName = "com.example.myapplication";
281  let bundleFlags = bundleResourceManager.ResourceFlag.GET_RESOURCE_INFO_ALL;
282  try {
283    let resourceInfo = bundleResourceManager.getBundleResourceInfo(bundleName, bundleFlags);
284    hilog.info(0x0000, 'testTag', 'getBundleResourceInfo successfully. Data label: %{public}s', JSON.stringify(resourceInfo.label));
285
286    let packageName:string = bundleName;
287    let index:number = resourceInfo.appIndex;
288    storageStatistics.getBundleStats(packageName, index).then((BundleStats: storageStatistics.BundleStats) => {
289      hilog.info(0x0000, 'testTag', 'getBundleStats successfully. BundleStats: %{public}s', JSON.stringify(BundleStats));
290    }).catch((err: BusinessError) => {
291      hilog.error(0x0000, 'testTag', 'getBundleStats failed with error: %{public}s', JSON.stringify(err));
292    });
293
294  } catch (err) {
295    let message = (err as BusinessError).message;
296    hilog.error(0x0000, 'testTag', 'getBundleResourceInfo failed with error: %{public}s', message);
297  }
298  ```
299
300## storageStatistics.getBundleStats<sup>9+</sup>
301
302getBundleStats(packageName: string,  callback: AsyncCallback&lt;BundleStats&gt;, index?: number): void
303
304Obtains the storage space of an application, in bytes. This API uses an asynchronous callback to return the result.
305
306**Required permissions**: ohos.permission.STORAGE_MANAGER
307
308**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
309
310**System API**: This is a system API.
311
312**Parameters**
313
314  | Name  | Type                                                     | Mandatory| Description                                |
315  | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
316  | packageName | string | Yes  | Package name of the application.|
317  | callback | AsyncCallback&lt;[Bundlestats](js-apis-file-storage-statistics.md#bundlestats9)&gt; | Yes  | Callback used to return the application storage space obtained.|
318  | index<sup>12+</sup> | number | No  | Index of an application clone. The default value is **0**, which indicates the application itself. When an application clone is created, an index is assigned from 1 sequentially to **appIndex** of [BundleResourceInfo](../apis-ability-kit/js-apis-bundleManager-BundleResourceInfo-sys.md#bundleresourceinfo). The index can be obtained by [getBundleResourceInfo](../apis-ability-kit/js-apis-bundleResourceManager-sys.md#bundleresourcemanagergetbundleresourceinfo12).|
319
320**Error codes**
321
322For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
323
324| ID| Error Message|
325| -------- | -------- |
326| 201 | Permission verification failed. |
327| 202 | The caller is not a system application. |
328| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
329| 13600001 | IPC error. |
330| 13600008 | No such object. |
331| 13900042 | Unknown error. |
332
333**Example**
334
335  ```ts
336  import bundleResourceManager from '@ohos.bundle.bundleResourceManager';
337  import storageStatistics from "@ohos.file.storageStatistics";
338  import { BusinessError } from '@ohos.base';
339  import { hilog } from '@kit.PerformanceAnalysisKit';
340
341  let bundleName = "com.example.myapplication";
342  let bundleFlags = bundleResourceManager.ResourceFlag.GET_RESOURCE_INFO_ALL;
343  try {
344    let resourceInfo = bundleResourceManager.getBundleResourceInfo(bundleName, bundleFlags);
345    hilog.info(0x0000, 'testTag', 'getBundleResourceInfo successfully. Data label: %{public}s', JSON.stringify(resourceInfo.label));
346
347    let packageName:string = bundleName;
348    let index:number = resourceInfo.appIndex;
349    storageStatistics.getBundleStats(packageName, (err: BusinessError, BundleStats: storageStatistics.BundleStats) => {
350      if (err) {
351        hilog.error(0x0000, 'testTag', 'getBundleStats failed with error: %{public}s', JSON.stringify(err));
352      } else {
353        hilog.info(0x0000, 'testTag', 'getBundleStats successfully. BundleStats: %{public}s', JSON.stringify(BundleStats));
354      }
355    }, index);
356
357  } catch (err) {
358    let message = (err as BusinessError).message;
359    hilog.error(0x0000, 'testTag', 'getBundleResourceInfo failed: %{public}s', message);
360  }
361  ```
362
363## storageStatistics.getSystemSize<sup>9+</sup>
364
365getSystemSize(): Promise&lt;number&gt;
366
367Obtains the system data size, in bytes. This API uses a promise to return the result.
368
369**Required permissions**: ohos.permission.STORAGE_MANAGER
370
371**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
372
373**System API**: This is a system API.
374
375**Return value**
376
377  | Type                 | Description            |
378  | --------------------- | ---------------- |
379  | Promise&lt;number&gt; | Promise used to return the system data size (in bytes) obtained.|
380
381**Error codes**
382
383For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
384
385| ID| Error Message|
386| -------- | -------- |
387| 201 | Permission verification failed. |
388| 202 | The caller is not a system application. |
389| 401 | The input parameter is invalid. Possible causes: Mandatory parameters are left unspecified. |
390| 13600001 | IPC error. |
391| 13900042 | Unknown error. |
392
393**Example**
394
395  ```ts
396  import { BusinessError } from '@ohos.base';
397  storageStatistics.getSystemSize().then((number: number) => {
398    console.info("getSystemSize successfully:" + number);
399  }).catch((err: BusinessError) => {
400    console.error("getSystemSize failed with error:" + JSON.stringify(err));
401  });
402  ```
403
404## storageStatistics.getSystemSize<sup>9+</sup>
405
406getSystemSize(callback: AsyncCallback&lt;number&gt;): void
407
408Obtains the system data size, in bytes. This API uses an asynchronous callback to return the result.
409
410**Required permissions**: ohos.permission.STORAGE_MANAGER
411
412**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
413
414**System API**: This is a system API.
415
416**Parameters**
417
418  | Name    | Type                                | Mandatory| Description                      |
419  | ---------- | ------------------------------------ | ---- | -------------------------- |
420  | callback   |  AsyncCallback&lt;number&gt;         | Yes  | Callback used to return the system data size obtained.|
421
422**Error codes**
423
424For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
425
426| ID| Error Message|
427| -------- | -------- |
428| 201 | Permission verification failed. |
429| 202 | The caller is not a system application. |
430| 401 | The input parameter is invalid. Possible causes: Mandatory parameters are left unspecified. |
431| 13600001 | IPC error. |
432| 13900042 | Unknown error. |
433
434**Example**
435
436  ```ts
437  import { BusinessError } from '@ohos.base';
438  storageStatistics.getSystemSize((error: BusinessError, number: number) => {
439    if (error) {
440      console.error("getSystemSize failed with error:" + JSON.stringify(error));
441    } else {
442      // Do something.
443      console.info("getSystemSize successfully:" + number);
444    }
445  });
446  ```
447
448## storageStatistics.getUserStorageStats<sup>9+</sup>
449
450getUserStorageStats(): Promise&lt;StorageStats&gt;
451
452Obtains the storage statistics of this user, in bytes. This API uses a promise to return the result.
453
454**Required permissions**: ohos.permission.STORAGE_MANAGER
455
456**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
457
458**System API**: This is a system API.
459
460**Return value**
461
462  | Type                 | Description            |
463  | --------------------- | ---------------- |
464  | Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the storage statistics (in bytes) obtained.|
465
466**Error codes**
467
468For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
469
470| ID| Error Message|
471| -------- | -------- |
472| 201 | Permission verification failed. |
473| 202 | The caller is not a system application. |
474| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
475| 13600001 | IPC error. |
476| 13900042 | Unknown error. |
477
478**Example**
479
480  ```ts
481  import { BusinessError } from '@ohos.base';
482  storageStatistics.getUserStorageStats().then((storageStats: storageStatistics.StorageStats) => {
483    console.info("getUserStorageStats successfully:" + JSON.stringify(storageStats));
484  }).catch((err: BusinessError) => {
485    console.error("getUserStorageStats failed with error:" + JSON.stringify(err));
486  });
487  ```
488
489## storageStatistics.getUserStorageStats<sup>9+</sup>
490
491getUserStorageStats(callback: AsyncCallback&lt;StorageStats&gt;): void
492
493Obtains the storage statistics of this user, in bytes. This API uses an asynchronous callback to return the result.
494
495**Required permissions**: ohos.permission.STORAGE_MANAGER
496
497**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
498
499**System API**: This is a system API.
500
501**Parameters**
502
503  | Name    | Type                                | Mandatory| Description                      |
504  | ---------- | ------------------------------------ | ---- | -------------------------- |
505  | callback   | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes  | Callback used to return the storage statistics obtained.|
506
507**Error codes**
508
509For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
510
511| ID| Error Message|
512| -------- | -------- |
513| 201 | Permission verification failed. |
514| 202 | The caller is not a system application. |
515| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
516| 13600001 | IPC error. |
517| 13900042 | Unknown error. |
518
519**Example**
520
521  ```ts
522  import { BusinessError } from '@ohos.base';
523  storageStatistics.getUserStorageStats((error: BusinessError, storageStats: storageStatistics.StorageStats) => {
524    if (error) {
525      console.error("getUserStorageStats failed with error:" + JSON.stringify(error));
526    } else {
527      // Do something.
528      console.info("getUserStorageStats successfully:" + JSON.stringify(storageStats));
529    }
530  });
531  ```
532
533## storageStatistics.getUserStorageStats<sup>9+</sup>
534
535getUserStorageStats(userId: number): Promise&lt;StorageStats&gt;
536
537Obtains the storage statistics of the specified user, in bytes. This API uses a promise to return the result.
538
539**Required permissions**: ohos.permission.STORAGE_MANAGER
540
541**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
542
543**System API**: This is a system API.
544
545**Parameters**
546
547  | Name    | Type  | Mandatory| Description|
548  | ---------- | ------ | ---- | ---- |
549  | userId | number | Yes  | User ID.|
550
551**Return value**
552
553  | Type                 | Description            |
554  | --------------------- | ---------------- |
555  | Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the storage statistics (in bytes) obtained.|
556
557**Error codes**
558
559For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
560
561| ID| Error Message|
562| -------- | -------- |
563| 201 | Permission verification failed. |
564| 202 | The caller is not a system application. |
565| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
566| 13600001 | IPC error. |
567| 13600009 | User if out of range. |
568| 13900042 | Unknown error. |
569
570**Example**
571
572  ```ts
573  import { BusinessError } from '@ohos.base';
574  let userId: number = 100;
575  storageStatistics.getUserStorageStats(userId).then((storageStats: storageStatistics.StorageStats) => {
576    console.info("getUserStorageStats successfully:" + JSON.stringify(storageStats));
577  }).catch((err: BusinessError) => {
578    console.error("getUserStorageStats failed with error:" + JSON.stringify(err));
579  });
580  ```
581
582## storageStatistics.getUserStorageStats<sup>9+</sup>
583
584getUserStorageStats(userId: number, callback: AsyncCallback&lt;StorageStats&gt;): void
585
586Obtains the storage statistics of the specified user, in bytes. This API uses an asynchronous callback to return the result.
587
588**Required permissions**: ohos.permission.STORAGE_MANAGER
589
590**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
591
592**System API**: This is a system API.
593
594**Parameters**
595
596  | Name    | Type                                | Mandatory| Description                      |
597  | ---------- | ------------------------------------ | ---- | -------------------------- |
598  | userId | number                               | Yes  | User ID.|
599  | callback   | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes  | Callback used to return the storage statistics obtained.|
600
601**Error codes**
602
603For details about the error codes, see [File Management Error Codes](errorcode-filemanagement.md).
604
605| ID| Error Message|
606| -------- | -------- |
607| 201 | Permission verification failed. |
608| 202 | The caller is not a system application. |
609| 401 | The input parameter is invalid. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
610| 13600001 | IPC error. |
611| 13600009 | User if out of range. |
612| 13900042 | Unknown error. |
613
614**Example**
615
616  ```ts
617  import { BusinessError } from '@ohos.base';
618  let userId: number = 100;
619  storageStatistics.getUserStorageStats(userId, (error: BusinessError, storageStats: storageStatistics.StorageStats) => {
620    if (error) {
621      console.error("getUserStorageStats failed with error:" + JSON.stringify(error));
622    } else {
623      // Do something.
624      console.info("getUserStorageStats successfully:" + JSON.stringify(storageStats));
625    }
626  });
627  ```
628
629## StorageStats<sup>9+</sup>
630
631**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
632
633**System API**: This is a system API.
634
635| Name     | Type  | Read-Only | Optional | Description          |
636| --------- | ------ | ---- | ----- | -------------- |
637| total   | number | No| No| Total space of the built-in storage, in bytes.   |
638| audio | number  |No| No| Size of the audio data, in bytes. |
639| video  | number | No| No| Size of the video data, in bytes.|
640| image   | number | No| No| Size of the image data, in bytes.  |
641| file | number | No| No| Size of files, in bytes. |
642| app  | number | No| No| Size of application data, in bytes.|
643