js-apis-storage-statistics.md 17.7 KB
Newer Older
A
annie_wangli 已提交
1 2
# App Storage Statistics

A
Annie_wang 已提交
3 4
The **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.

A
Annie_wang 已提交
5
> **NOTE**<br/>
A
annie_wangli 已提交
6
>
A
annie_wangli 已提交
7
> - 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.
A
Annie_wang 已提交
8 9
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.

A
annie_wangli 已提交
10 11 12
## Modules to Import

```js
A
Annie_wang 已提交
13
import storageStatistics from "@ohos.storageStatistics";
A
annie_wangli 已提交
14 15
```

A
Annie_wang 已提交
16
## storageStatistics.getTotalSizeOfVolume
A
annie_wangli 已提交
17 18 19

getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;

A
Annie_wang 已提交
20 21 22
Asynchronously obtains the total size of the specified volume. This API uses a promise to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER
A
annie_wangli 已提交
23

A
annie_wangli 已提交
24 25
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics

A
Annie_wang 已提交
26

A
Annie_wang 已提交
27 28 29 30
This is a system API and cannot be called by third-party applications.


**Parameters**
A
annie_wangli 已提交
31

A
annie_wangli 已提交
32
  | Name    | Type  | Mandatory| Description|
A
annie_wangli 已提交
33
  | ---------- | ------ | ---- | ---- |
A
annie_wangli 已提交
34
  | volumeUuid | string | Yes  | UUID of the volume.|
A
annie_wangli 已提交
35

A
Annie_wang 已提交
36
**Return value**
A
annie_wangli 已提交
37

A
annie_wangli 已提交
38
  | Type                 | Description            |
A
annie_wangli 已提交
39
  | --------------------- | ---------------- |
A
Annie_wang 已提交
40
  | Promise&lt;number&gt; | Promise used to return the total size of the volume.|
A
annie_wangli 已提交
41

A
Annie_wang 已提交
42
**Example**
A
annie_wangli 已提交
43 44 45

  ```js
  let uuid = "";
A
Annie_wang 已提交
46
  storageStatistics.getTotalSizeOfVolume(uuid).then(function(number){
A
annie_wangli 已提交
47 48 49 50 51 52
      console.info("getTotalSizeOfVolume successfully:"+ number);
  }).catch(function(err){
      console.info("getTotalSizeOfVolume failed with error:"+ err);
  });
  ```

A
Annie_wang 已提交
53
## storageStatistics.getTotalSizeOfVolume
A
annie_wangli 已提交
54 55 56

getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void

A
Annie_wang 已提交
57 58 59
Asynchronously obtains the total size of the specified volume. This API uses a callback to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER
A
annie_wangli 已提交
60

A
annie_wangli 已提交
61 62
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics

A
Annie_wang 已提交
63

A
Annie_wang 已提交
64 65 66 67
This is a system API and cannot be called by third-party applications.


**Parameters**
A
annie_wangli 已提交
68

A
annie_wangli 已提交
69
  | Name    | Type                                | Mandatory| Description                      |
A
annie_wangli 已提交
70
  | ---------- | ------------------------------------ | ---- | -------------------------- |
A
annie_wangli 已提交
71
  | volumeUuid | string                               | Yes  | UUID of the volume.                      |
A
Annie_wang 已提交
72
  | callback   | callback:AsyncCallback&lt;number&gt; | Yes  | Callback invoked to return the total size of the volume.|
A
annie_wangli 已提交
73

A
Annie_wang 已提交
74
**Example**
A
annie_wangli 已提交
75 76 77

  ```js
  let uuid = "";
A
Annie_wang 已提交
78
  storageStatistics.getTotalSizeOfVolume(uuid, function(error, number){
A
Annie_wang 已提交
79
      // Do something.
A
annie_wangli 已提交
80
      console.info("getTotalSizeOfVolume successfully:"+ number);
A
annie_wangli 已提交
81 82 83
  });
  ```

A
Annie_wang 已提交
84
## storageStatistics.getFreeSizeOfVolume
A
annie_wangli 已提交
85 86 87

getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;

A
Annie_wang 已提交
88
Asynchronously obtains the available space of the specified volume. This API uses a promise to return the result.
A
annie_wangli 已提交
89

A
Annie_wang 已提交
90 91
**Required permissions**: ohos.permission.STORAGE_MANAGER

A
annie_wangli 已提交
92 93
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics

A
Annie_wang 已提交
94

A
Annie_wang 已提交
95 96 97 98
This is a system API and cannot be called by third-party applications.


**Parameters**
A
annie_wangli 已提交
99

A
annie_wangli 已提交
100
  | Name    | Type  | Mandatory| Description|
A
annie_wangli 已提交
101
  | ---------- | ------ | ---- | ---- |
A
annie_wangli 已提交
102
  | volumeUuid | string | Yes  | UUID of the volume.|
A
annie_wangli 已提交
103

A
Annie_wang 已提交
104
**Return value**
A
annie_wangli 已提交
105

A
annie_wangli 已提交
106
  | Type                 | Description              |
A
annie_wangli 已提交
107 108 109
  | --------------------- | ------------------ |
  | Promise&lt;number&gt; | Promise used to return the available space of the volume.|

A
Annie_wang 已提交
110
**Example**
A
annie_wangli 已提交
111 112 113

  ```js
  let uuid = "";
A
Annie_wang 已提交
114
  storageStatistics.getFreeSizeOfVolume(uuid).then(function(number){
A
annie_wangli 已提交
115 116 117 118 119 120 121
      console.info("getFreeSizeOfVolume successfully:"+ number);
  }).catch(function(err){
      console.info("getFreeSizeOfVolume failed with error:"+ err);
  });
  
  ```

A
Annie_wang 已提交
122
## storageStatistics.getFreeSizeOfVolume
A
annie_wangli 已提交
123 124 125

getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void

A
Annie_wang 已提交
126
Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result.
A
annie_wangli 已提交
127

A
Annie_wang 已提交
128 129
**Required permissions**: ohos.permission.STORAGE_MANAGER

A
annie_wangli 已提交
130 131
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics

A
Annie_wang 已提交
132

A
Annie_wang 已提交
133 134 135 136
This is a system API and cannot be called by third-party applications.


**Parameters**
A
annie_wangli 已提交
137

A
annie_wangli 已提交
138
  | Name    | Type                                | Mandatory| Description                        |
A
annie_wangli 已提交
139
  | ---------- | ------------------------------------ | ---- | ---------------------------- |
A
annie_wangli 已提交
140 141
  | volumeUuid | string                               | Yes  | UUID of the volume.                        |
  | callback   | callback:AsyncCallback&lt;number&gt; | Yes  | Callback invoked to return the available space of the volume.|
A
annie_wangli 已提交
142

A
Annie_wang 已提交
143
**Example**
A
annie_wangli 已提交
144 145 146

  ```js
  let uuid = "";
A
Annie_wang 已提交
147
  storageStatistics.getFreeSizeOfVolume(uuid, function(error, number){
A
Annie_wang 已提交
148
      // Do something.
A
annie_wangli 已提交
149
      console.info("getFreeSizeOfVolume successfully:"+ number);
A
annie_wangli 已提交
150 151 152
  });
  ```

A
Annie_wang 已提交
153
## storageStatistics.getBundleStats<sup>9+</sup>
A
annie_wangli 已提交
154

A
annie_wangli 已提交
155
getBundleStats(packageName: string): Promise&lt;BundleStats&gt;
A
annie_wangli 已提交
156

A
Annie_wang 已提交
157
Asynchronously obtains space information of an application. This API uses a promise to return the result.
A
Annie_wang 已提交
158 159

**Required permissions**: ohos.permission.STORAGE_MANAGER
A
annie_wangli 已提交
160 161

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
A
annie_wangli 已提交
162

A
Annie_wang 已提交
163

A
Annie_wang 已提交
164 165 166 167
This is a system API and cannot be called by third-party applications.


**Parameters**
A
annie_wangli 已提交
168

A
annie_wangli 已提交
169
  | Name     | Type  | Mandatory| Description    |
A
annie_wangli 已提交
170
  | ----------- | ------ | ---- | -------- |
A
Annie_wang 已提交
171
  | packageName | string | Yes  | Bundle name of the application.|
A
Annie_wang 已提交
172 173

**Return value**
A
annie_wangli 已提交
174

A
annie_wangli 已提交
175
  | Type                                      | Description                      |
A
annie_wangli 已提交
176
  | ------------------------------------------ | -------------------------- |
A
Annie_wang 已提交
177
  | Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.|
A
annie_wangli 已提交
178

A
Annie_wang 已提交
179
**Example**
A
annie_wangli 已提交
180 181 182

  ```js
  let packageName = "";
A
Annie_wang 已提交
183
  storageStatistics.getBundleStats(packageName).then(function(BundleStats){
A
annie_wangli 已提交
184 185 186 187 188 189
      console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
  }).catch(function(err){
      console.info("getBundleStats failed with error:"+ err);
  });
  ```

A
Annie_wang 已提交
190
## storageStatistics.getBundleStats<sup>9+</sup>
A
annie_wangli 已提交
191

A
annie_wangli 已提交
192
getBundleStats(packageName: string,  callback: AsyncCallback&lt;BundleStats&gt;): void
A
annie_wangli 已提交
193

A
Annie_wang 已提交
194
Asynchronously obtains space information of an application. This API uses a callback to return the result.
A
Annie_wang 已提交
195 196

**Required permissions**: ohos.permission.STORAGE_MANAGER
A
annie_wangli 已提交
197

A
annie_wangli 已提交
198
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
A
annie_wangli 已提交
199

A
Annie_wang 已提交
200

A
Annie_wang 已提交
201 202 203 204
This is a system API and cannot be called by third-party applications.


**Parameters**
A
annie_wangli 已提交
205

A
annie_wangli 已提交
206 207
  | Name  | Type                                                     | Mandatory| Description                                |
  | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
A
Annie_wang 已提交
208
  | packageName | string | Yes  | Bundle name of the application.|
A
Annie_wang 已提交
209
  | callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes  | Callback invoked to return the space information obtained.|
A
Annie_wang 已提交
210 211

**Example**
A
annie_wangli 已提交
212 213 214

  ```js
  let packageName = "";
A
Annie_wang 已提交
215
  storageStatistics.getBundleStats(packageName, function(error, BundleStats){
A
Annie_wang 已提交
216
      // Do something.
A
annie_wangli 已提交
217
      console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
A
annie_wangli 已提交
218 219 220
  });
  ```

A
Annie_wang 已提交
221
## storageStatistics.getCurrentBundleStats<sup>9+</sup>
A
Annie_wang 已提交
222

A
Annie_wang 已提交
223
getCurrentBundleStats(): Promise&lt;BundleStats&gt;
A
Annie_wang 已提交
224

A
Annie_wang 已提交
225
Asynchronously obtains space information of the current third-party application. This API uses a promise to return the result.
A
Annie_wang 已提交
226 227 228

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics

A
Annie_wang 已提交
229
**Return value**
A
Annie_wang 已提交
230 231 232

  | Type                                       | Description                      |
  | ------------------------------------------ | -------------------------- |
A
Annie_wang 已提交
233
  | Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.     |
A
Annie_wang 已提交
234

A
Annie_wang 已提交
235
**Example**
A
Annie_wang 已提交
236 237

  ```js
A
Annie_wang 已提交
238 239
  let bundleStats = storageStatistics.getCurrentBundleStats();
  console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
A
Annie_wang 已提交
240 241
  ```

A
Annie_wang 已提交
242
## storageStatistics.getCurrentBundleStats<sup>9+</sup>
A
Annie_wang 已提交
243

A
Annie_wang 已提交
244
getCurrentBundleStats(callback: AsyncCallback&lt;BundleStats&gt;): void
A
Annie_wang 已提交
245

A
Annie_wang 已提交
246 247
Asynchronously obtains space information of the current third-party application. This API uses a callback to return the result.

A
Annie_wang 已提交
248 249
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics

A
Annie_wang 已提交
250
**Parameters**
A
Annie_wang 已提交
251 252 253

  | Name   | Type                                                      | Mandatory | Description                                |
  | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
A
Annie_wang 已提交
254
  | callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes  | Callback invoked to return the space information obtained.       |
A
Annie_wang 已提交
255

A
Annie_wang 已提交
256
**Example**
A
Annie_wang 已提交
257 258

  ```js
A
Annie_wang 已提交
259
  storageStatistics.getCurrentBundleStats(function(error, bundleStats){
A
Annie_wang 已提交
260 261 262 263
      // Do something.
      console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
  });
  ```
A
Annie_wang 已提交
264

A
annie_wangli 已提交
265 266
## BundleStats<sup>9+</sup>

A
Annie_wang 已提交
267 268
### Attributes

A
annie_wangli 已提交
269
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
A
annie_wangli 已提交
270

A
Annie_wang 已提交
271 272 273

This is a system API and cannot be called by third-party applications.

A
Annie_wang 已提交
274 275 276 277 278 279 280
| Name     | Type  | Description          |
| --------- | ------ | -------------- |
| appSize   | number | Size of the application.   |
| cacheSize | number | Cache size of the application.  |
| dataSize  | number | Total data size of the application.|


A
Annie_wang 已提交
281
## storageStatistics.getTotalSize<sup>9+</sup>
A
Annie_wang 已提交
282

A
Annie_wang 已提交
283
getTotalSize(): Promise&lt;number&gt;
A
Annie_wang 已提交
284 285 286 287 288 289 290 291

Obtains the total space of the built-in memory card. This API uses a promise to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics


A
Annie_wang 已提交
292 293 294 295
This is a system API and cannot be called by third-party applications.


**Return value**
A
Annie_wang 已提交
296 297 298 299 300

  | Type                  | Description              |
  | --------------------- | ------------------ |
  | Promise&lt;number&gt; | Promise used to return the total space of the built-in memory card.  |

A
Annie_wang 已提交
301
**Example**
A
Annie_wang 已提交
302 303

  ```js
A
Annie_wang 已提交
304 305
  let number = storageStatistics.getTotalSize();
  console.info("getTotalSize successfully:"+ JSON.stringify(number));
A
Annie_wang 已提交
306 307
  ```

A
Annie_wang 已提交
308 309 310
## storageStatistics.getTotalSize<sup>9+</sup>

getTotalSize(callback: AsyncCallback&lt;number&gt;): void
A
Annie_wang 已提交
311 312 313 314 315 316 317 318

Obtains the total space of the built-in memory card. This API uses a callback to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics


A
Annie_wang 已提交
319 320 321 322
This is a system API and cannot be called by third-party applications.


**Parameters**
A
Annie_wang 已提交
323 324 325 326 327

  | Name   | Type                                 | Mandatory | Description                    |
  | -------- | ------------------------------------ | ---- | ------------------------ |
  | callback | callback:AsyncCallback&lt;number&gt; | Yes  | Callback invoked to return the total space of the built-in memory card.|

A
Annie_wang 已提交
328
**Example**
A
Annie_wang 已提交
329 330

  ```js
A
Annie_wang 已提交
331
  storageStatistics.getTotalSize(function(error, number){
A
Annie_wang 已提交
332 333 334 335 336 337
      // Do something.
      console.info("getTotalSize successfully:"+ JSON.stringify(number));
  });
  ```


A
Annie_wang 已提交
338
## storageStatistics.getFreeSize<sup>9+</sup>
A
Annie_wang 已提交
339

A
Annie_wang 已提交
340
getFreeSize(): Promise&lt;number&gt;
A
Annie_wang 已提交
341 342 343 344 345 346 347 348

Obtains the available space of the built-in memory card. This API uses a promise to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics


A
Annie_wang 已提交
349 350 351 352
This is a system API and cannot be called by third-party applications.


**Return value**
A
Annie_wang 已提交
353 354 355 356 357

  | Type                  | Description              |
  | --------------------- | ------------------ |
  | Promise&lt;number&gt; | Promise used to return the available space of the built-in memory card.|

A
Annie_wang 已提交
358
**Example**
A
Annie_wang 已提交
359 360

  ```js
A
Annie_wang 已提交
361 362
  let number = storageStatistics.getFreeSize();
  console.info("getFreeSize successfully:"+ JSON.stringify(number));
A
Annie_wang 已提交
363 364 365
  ```


A
Annie_wang 已提交
366
## storageStatistics.getFreeSize<sup>9+</sup>
A
Annie_wang 已提交
367

A
Annie_wang 已提交
368
getFreeSize(callback: AsyncCallback&lt;number&gt;): void
A
Annie_wang 已提交
369 370 371 372 373 374 375 376

Obtains the available space of the built-in memory card. This API uses a callback to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics


A
Annie_wang 已提交
377 378 379 380
This is a system API and cannot be called by third-party applications.


**Parameters**
A
Annie_wang 已提交
381 382 383 384 385

  | Name   | Type                                 | Mandatory| Description                      |
  | -------- | ------------------------------------ | ---- | ------------------------- |
  | callback | callback:AsyncCallback&lt;number&gt; | Yes  | Callback invoked to return the available space of the built-in memory card.|

A
Annie_wang 已提交
386
**Example**
A
Annie_wang 已提交
387 388

  ```js
A
Annie_wang 已提交
389
  storageStatistics.getFreeSize(function(error, number){
A
Annie_wang 已提交
390 391 392 393 394
      // Do something.
      console.info("getFreeSize successfully:"+ JSON.stringify(number));
  });
  ```

A
Annie_wang 已提交
395
## storageStatistics.getSystemSize<sup>9+</sup>
A
Annie_wang 已提交
396 397 398 399 400 401 402 403 404 405

getSystemSize(): Promise&lt;number&gt;

Asynchronously obtains the system space. This API uses a promise to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics


A
Annie_wang 已提交
406 407 408 409
This is a system API and cannot be called by third-party applications.


**Return value**
A
Annie_wang 已提交
410 411 412 413 414

  | Type                 | Description            |
  | --------------------- | ---------------- |
  | Promise&lt;number&gt; | Promise used to return the system space obtained.|

A
Annie_wang 已提交
415
**Example**
A
Annie_wang 已提交
416 417

  ```js
A
Annie_wang 已提交
418
  storageStatistics.getSystemSize().then(function(number){
A
Annie_wang 已提交
419 420 421 422 423 424
      console.info("getSystemSize successfully:"+ number);
  }).catch(function(err){
      console.info("getSystemSize failed with error:"+ err);
  });
  ```

A
Annie_wang 已提交
425
## storageStatistics.getSystemSize<sup>9+</sup>
A
Annie_wang 已提交
426 427 428 429 430 431 432 433 434 435

getSystemSize(callback:AsyncCallback&lt;number&gt;):void

Asynchronously obtains the system space. This API uses a callback to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics


A
Annie_wang 已提交
436 437 438 439
This is a system API and cannot be called by third-party applications.


**Parameters**
A
Annie_wang 已提交
440 441 442 443 444

  | Name    | Type                                | Mandatory| Description                      |
  | ---------- | ------------------------------------ | ---- | -------------------------- |
  | callback   | callback:AsyncCallback&lt;number&gt; | Yes  | Callback used to return the system space obtained.|

A
Annie_wang 已提交
445
**Example**
A
Annie_wang 已提交
446 447

  ```js
A
Annie_wang 已提交
448
  storageStatistics.getSystemSize(function(error, number){
A
Annie_wang 已提交
449 450 451 452 453
      // Do something.
      console.info("getSystemSize successfully:"+ number);
  });
  ```

A
Annie_wang 已提交
454 455 456
## storageStatistics.getUserStorageStats<sup>9+</sup>

getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt;
A
Annie_wang 已提交
457 458 459 460 461 462 463 464

Asynchronously obtains the space occupied by each type of user data. This API uses a promise to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics


A
Annie_wang 已提交
465 466 467 468
This is a system API and cannot be called by third-party applications.


**Parameters**
A
Annie_wang 已提交
469 470 471

  | Name    | Type  | Mandatory| Description|
  | ---------- | ------ | ---- | ---- |
A
Annie_wang 已提交
472
  | userId | number | No  | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.|
A
Annie_wang 已提交
473

A
Annie_wang 已提交
474
**Return value**
A
Annie_wang 已提交
475 476 477 478 479

  | Type                 | Description            |
  | --------------------- | ---------------- |
  | Promise&lt;[StorageStats](#StorageStats)&gt; | Promise used to return the information obtained.|

A
Annie_wang 已提交
480
**Example**
A
Annie_wang 已提交
481 482

  ```js
A
Annie_wang 已提交
483
  let userId = 1;
A
Annie_wang 已提交
484
  storageStatistics.getUserStorageStats(userId).then(function(StorageStats){
A
Annie_wang 已提交
485 486 487 488 489 490
      console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
  }).catch(function(err){
      console.info("getUserStorageStats failed with error:"+ err);
  });
  ```

A
Annie_wang 已提交
491
## storageStatistics.getUserStorageStats<sup>9+</sup>
A
Annie_wang 已提交
492

A
Annie_wang 已提交
493
getUserStorageStats(userId: number, callback:AsyncCallback&lt;StorageStats&gt;):void
A
Annie_wang 已提交
494 495 496 497 498 499 500 501

Asynchronously obtains the space occupied by each type of user data. This API uses a callback to return the result.

**Required permissions**: ohos.permission.STORAGE_MANAGER

**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics


A
Annie_wang 已提交
502 503 504 505
This is a system API and cannot be called by third-party applications.


**Parameters**
A
Annie_wang 已提交
506 507 508

  | Name    | Type                                | Mandatory| Description                      |
  | ---------- | ------------------------------------ | ---- | -------------------------- |
A
Annie_wang 已提交
509
  | userId | number                               | No  | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.                      |
A
Annie_wang 已提交
510 511
  | callback   | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | Yes  | Callback invoked to return the information obtained.|

A
Annie_wang 已提交
512
**Example**
A
Annie_wang 已提交
513 514

  ```js
A
Annie_wang 已提交
515
  let userId = 1;
A
Annie_wang 已提交
516
  storageStatistics.getUserStorageStats(userId, function(error, StorageStats){
A
Annie_wang 已提交
517 518 519 520 521 522 523 524
      // Do something.
      console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
  });
  ```


## StorageStats<sup>9+</sup>

A
Annie_wang 已提交
525 526
### Attributes

A
Annie_wang 已提交
527 528
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics

A
Annie_wang 已提交
529 530 531

This is a system API and cannot be called by third-party applications.

A
annie_wangli 已提交
532
| Name     | Type  | Description          |
A
annie_wangli 已提交
533
| --------- | ------ | -------------- |
A
Annie_wang 已提交
534
| total   | number | Total space of the built-in memory card.   |
A
Annie_wang 已提交
535 536 537
| audio | number | Space occupied by audio data.  |
| video  | number | Space occupied by video data.|
| image   | number | Space occupied by image data.   |
A
Annie_wang 已提交
538
| file | number | Space occupied by files.  |
A
Annie_wang 已提交
539
| app  | number | Space occupied by application data.|