From 57ddb134e3901af277a1c94070f7e0b4046bd04b Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Wed, 16 Feb 2022 18:28:35 +0800 Subject: [PATCH] add doc Signed-off-by: ester.zhou --- .../reference/apis/js-apis-environment.md | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 en/application-dev/reference/apis/js-apis-environment.md diff --git a/en/application-dev/reference/apis/js-apis-environment.md b/en/application-dev/reference/apis/js-apis-environment.md new file mode 100644 index 0000000000..c0b761a179 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-environment.md @@ -0,0 +1,98 @@ +# Environment + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> 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. + +## Modules to Import + +```js +import environment from '@ohos.environment'; +``` + +## System Capabilities + +SystemCapability.FileManagement.File.Environment + +## environment.getStorageDataDir + +getStorageDataDir():Promise<string> + +Obtains the root directory of the storage. This method uses a promise to return the result. + +- Return value + + | Type| Description| + | --------------------- | ---------------- | + | Promise<string> | Promise returned with the root directory of the storage.| + +- Example + + ```js + environment.getStorageDataDir().then(function(path){ + console.info("getStorageDataDir successfully:"+ path); + }).catch(function(error){ + console.info("getStorageDataDir failed with error:"+ error); + }); + ``` + +## environment.getStorageDataDir + +getStorageDataDir(callback:AsyncCallback<string>):void + +Obtains the root directory of the storage. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | --------------------------- | ---- | -------------------------------- | + | callback | AsyncCallback<string> | Yes| Asynchronous callback used to return the root directory of the storage.| + +- Example + + ```js + environment.getStorageDataDir(function(error, path){ + // do something + }); + ``` + +## environment.getUserDataDir + +getUserDataDir():Promise<string> + +Obtains the root directory of public files. This method uses a promise to return the result. + +- Return value + + | Type| Description| + | --------------------- | ------------------ | + | Promise<string> | Promise returned with the root directory of public files.| + +- Example + + ```js + environment.getUserDataDir().then(function(path){ + console.info("getUserDataDir successfully:"+ path); + }).catch(function(error){ + console.info("getUserDataDir failed with error:"+ error); + }); + ``` + +## environment.getUserDataDir + +getUserDataDir(callback:AsyncCallback<string>): void + +Obtains the root directory of public files. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | --------------------------- | ---- | -------------------------------- | + | callback | AsyncCallback<string> | Yes| Asynchronous callback used to return the root directory of public files.| + +- Example + + ```js + environment.getUserDataDir(function(error, path){ + // do something + }); + ``` -- GitLab