Class Storage#removeFile
storage
- Defined in: storage.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Storage#removeFile(successCallback, errorCallback, options)
Removes file in internal or external storage. |
Class Detail
Storage#removeFile(successCallback, errorCallback, options)
Removes file in internal or external storage. Target path is described in URI form.
If the target path is a file, it will be removed. If the target path is a directory, the directory will be removed. If 'recursive' parameter is 'true', any file or directory in the target directory will be removed. If 'recursive' parameter is 'false', operation will fail if there is any file in that directory.file://internal/external, file://usb:[index]/content are predefined directory for special use, and cannot be removed.
function removeFile() {
var successCb = function (){
console.log("Removing File done.");
};
var failureCb = function(cbObject){
var errorCode = cbObject.errorCode;
var errorText = cbObject.errorText;
console.log( " Error Code [" + errorCode + "]: " + errorText);
};
//delete a file
var options = {
file: 'file://internal/delete_me.txt',
};
var storage = new Storage();
storage.removeFile(successCb, failureCb, options);
//delete a directory and contents in it
var options = {
file: 'file://internal/delete/this/directory/',
recursive : true
};
storage.removeFile(successCb, failureCb, options);
//delete a directory, only if it's empty
var options = {
file: 'file://internal/empty/directory/',
recursive : false
};
storage.removeFile(successCb, failureCb, options);
}
- Parameters:
- {Function} successCallback
- success callback function.
- {Function} errorCallback
- failure callback function.
- {Object} options
Property Type Description Required file Storage.SCAP_URI URI to the file to delete required recursive Boolean only meaningful when removing a directory. Default value is 'false'. If true, the directory and all contents in it will be removed. If false, removing the directory will fail if it is not empty. optional
- Since:
- 1.0 1.1 options.recursive
- Returns:
After the method is successfully executed, successCallback is called without any parameter. If an error occurs, errorCallback is called with errorCode and errorText. To see how error codes are defined, check Error.ERROR_CODE