FileSystemManager.unlink
Introduction
Deletes a file.
Usage Restrictions
Supported in Basic Library version 3.0.0
or higher.
Parameters
Object object
Property | Type | Default | Required | Description |
---|---|---|---|---|
filePath | string | Yes | The file path (relative path) of the file to delete | |
success | function | No | Callback function executed upon successful API call | |
fail | function | No | Callback function executed upon failed API call | |
complete | function | No | Callback function executed upon API call completion (executed regardless of success or failure) |
object.success
Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | string | true - successful setting |
object.fail
Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
errMsg | string | Error message |
success | string | false - failed setting |
errMsg Explanation
Error message | Explanation |
---|---|
parameter error: F10001 | Invalid parameter |
fail sdcard not mounted: F10002 | Failed to mount Android sdcard |
fail permission denied: F10005, open ${filePath} | No read permission for specified filePath path |
fail no such file or directory: F10007, ${path} | File does not exist |
fail operation not permitted, unlink ${filePath} | filePath provided is a directory |
Sample Code
// pages/index/index.js
Page({
unlink() {
const fs = dlt.getFileSystemManager();
fs.unlink({
filePath: `${dlt.env.USER_DATA_PATH}/hello.txt`,
success(res) {
console.log(res);
},
fail(res) {
console.error(res);
},
});
},
});