Class Storage#exists
storage
- Defined in: storage.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Storage#exists(successCallback, errorCallback, options)
Checks if the given file exists or not. |
Class Detail
Storage#exists(successCallback, errorCallback, options)
Checks if the given file exists or not. The path should be in URI format. If the URI is for external memory, external storage device must be connected to the external memory port with proper permission.
function exists() {
var successCb = function (cbObject){
var exists = cbObject.exists;
console.log( "The file exists: " + exists);
};
var failureCb = function(cbObject){
var errorCode = cbObject.errorCode;
var errorText = cbObject.errorText;
console.log( " Error Code [" + errorCode + "]: " + errorText);
};
var existsOption = {
path: "file://internal/to/be/or/not/to/be"
};
var storage = new Storage();
storage.exists(successCb, failureCb, existsOption);
}
- Parameters:
- {Function} successCallback
- success callback function.
- {Function} errorCallback
- failure callback function.
- {Object} options
Property Type Description Required path Storage.SCAP_URI URI to the resource (internal/usb/sdcard). required
- Since:
- 1.1
- Returns:
After the method is successfully executed, successCallback is called with a boolean attribute 'exists', which is true if the file exists and false otherwise. If an error occurs, errorCallback is called with errorCode and errorText. To see how error codes are defined, check Error.ERROR_CODE