This API is available on Firefox OS for privileged or certified applications 仅。

摘要

freeSpace method is used to get the amount of free space usable by the storage area.

The request's result is a number representing the amount of free space expressed in 字节 .

句法

var instanceOfDOMRequest = instanceOfDeviceStorage.freeSpace();
					

返回

It returns a DOMRequest object to handle the success or error of the operation.

范例

var sdcard = navigator.getDeviceStorage("sdcard");
var request = sdcard.freeSpace();
request.onsuccess = function () {
  // The result is expressed in bytes, let's turn it into Gigabytes
  var size = this.result / Math.pow(10,9);
  console.log("You have " + size.toFixed(2) + "GB of free space on your SDCard.");
}
request.onerror = function () {
  console.warn("Unable to get the free space available for the SDCard: " + this.error);
}
					

规范

Not part of any specification.

另请参阅

元数据

  • 最后修改: