mozilla
Your Search Results

    DeviceStorage.available()

    This article is in need of a technical review.

    Non-standard
    This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

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

    Summary

    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:

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

    Syntax

    var instanceOfDOMRequest = instanceOfDeviceStorage.available();

    Returns

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

    Example

    var sdcard = navigator.getDeviceStorage("sdcard");
    
    var request = sdcard.available();
    
    request.onsuccess = function () {
      // The result is a string
    
      if (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 {
        console.log("The SDCard on your device is shared and thus not available");
      }
    }
    
    request.onerror = function () {
      console.warn("Unable to get the space used by the SDCard: " + this.error);
    }
    

    Specification

    Not part of any specification.

    See also

    Document Tags and Contributors

    Contributors to this page: jswisher, Sheppy, fscholz, Jeremie, teoli, alain, kscarfone, MBRSL
    Last updated by: fscholz,