Class Storage#getStorageInfo
storage
- Defined in: storage.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Storage#getStorageInfo(successCallback, errorCallback)
Gets internal memory status. |
Class Detail
Storage#getStorageInfo(successCallback, errorCallback)
Gets internal memory status. Returns free space and total space, in kilobytes. If any external storage device is connected, the storage info for that device will be returned as well.
function getStorageInfo() {
var successCb = function (cbObject){
var free = cbObject.free;
var total = cbObject.total;
var used = cbObject.used;
var externals = cbObject.externalMemory;
console.log( "Total: " + total + "kilobytes");
console.log( "Free: " + free + "kilobytes");
console.log( "Used: " + used + "kilobytes");
for(var uri in externals){
var external = externals[uri];
console.log("base uri: " + uri); // ex) usb:1
console.log("Free: " + external.free);
console.log("Used: " + external.used);
console.log("Total: " + external.total);
}
};
var failureCb = function(cbObject){
var errorCode = cbObject.errorCode;
var errorText = cbObject.errorText;
console.log( " Error Code [" + errorCode + "]: " + errorText);
};
var storage = new Storage();
storage.getStorageInfo(successCb, failureCb);
}
- Parameters:
- {Function} successCallback
- success callback function.
- {Function} errorCallback
- failure callback function.
- Since:
- 1.0, 1.1 USB storage information, 1.3 SDCard storage information
- Returns:
After the method is successfully executed, successCallback is called with free and total space.
Property Type Description free Number Free space in internal memory, in KB. total Number Total space in internal memory, in KB. used Number Used space in internal memory, in KB. externalMemory Array List of external memory connected to the device (ex.usb:1). Optional.
Each external memory item is a JSON object containing following fields.
Property Type Description free Number Free space in the external memory, in KB. used Number Used space in the external memory, in KB. total Number Total space in the external memory, in KB. If an error occurs, errorCallback is called with errorCode and errorText. To see how error codes are defined, check Error.ERROR_CODE