This API is available on Firefox OS for privileged or certified applications only.


The available() method is used to check whether the storage area is available; this is an asynchronous operation that returns a DOMRequest object that will receive a callback when the operation is complete.

The request's result may be:

Meaning that the storage area is available.
Meaning that the storage area is not available. E.g. The SD card has need been inserted.
Meaning the storage area is not available because the device is currently being used for USB storage.


var instanceOfDOMRequest = instanceOfDeviceStorage.available();


Returns a DOMRequest object to report the success or error of the operation.


var sdcard = navigator.getDeviceStorage("sdcard");</code><code class="language-js">

var request = sdcard.available();

request.onsuccess = function () {<s>
</s>  // The result is a string

  if (</code><code class="language-js">this.result == "available") {
    console.log("The SDCard on your device is available");
  } else if (this.result == "unavailable") {
    console.log("The SDcard on your device is not available");
  } else {
</code><code class="language-js">    console.log("The SDCard on your device is shared and thus not available");
</code><code class="language-js">  }</code><code class="language-js">

request.onerror = function () {
  console.warn("Unable to get the space used by the SDCard: " + this.error);


Not part of any specification.

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API B2G Device Storage Firefox OS Method Non-standard Reference Référence WebAPI