• Skip to main content
  • Select language
  • Skip to search
mozilla
Mozilla Developer Network
  • Sign in
    • Persona
    • GitHub
  • Web Platform
    Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • APIs / DOM
    • Apps
    • MathML
    References & Guides
    • Learn the Web
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • ...more docs
  • Mozilla Docs
    • Add-ons
    • Firefox
    • Firefox Marketplace
    • Firefox OS
    • Persona
  • Developer Tools
  • Feedback
    • Get Firefox help
    • Get web development help
    • Join the MDN community
    • Report a content problem
    • Report a bug
  •  
B2G OS
    • No translations exist for this article.
    • Add a translation
  • Edit
  • Advanced
    • History
    • Print this article
  1. MDN
  2. Mozilla
  3. B2G OS
  4. Firefox OS APIs
  5. DeviceStorage
  6. DeviceStorage.usedSpace()
Your Search Results

    DeviceStorage.usedSpace()

    In This Article
    1. Summary
    2. Syntax
      1. Returns
    3. Example
    4. Specification
    5. See also

    This article needs a technical review. How you can help.

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

    SummaryEdit

    The usedSpace method is used to get the total of space used by the storage (the amount of space filled by files).

    The request's result is a number representing the amount of available space expressed in Bytes.

    SyntaxEdit

    var instanceOfDOMRequest = instanceOfDeviceStorage.usedSpace();

    Returns

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

    ExampleEdit

    var sdcard = navigator.getDeviceStorage("sdcard");
    
    var request = sdcard.usedSpace();
    
    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("The files on your SDCard take " + size.toFixed(2) + "GB of space.");
    }
    
    request.onerror = function () {
      console.warn("Unable to get the space used by the SDCard: " + this.error);
    }

    SpecificationEdit

    Not part of any specification.

    See alsoEdit

    • DeviceStorage
    • DOMRequest
    • Device Storage API
    Share:
    • Twitter
    • Facebook
    • Google+

    Document Tags and Contributors

    Tags: 
    • API
    • B2G
    • Device Storage
    • Firefox OS
    • Method
    • Non Standard
    • Reference
    • Référence
     Contributors to this page: chrisdavidmills, fscholz, kscarfone, Jeremie
     Last updated by: chrisdavidmills, Feb 11, 2016, 3:35:04 AM
    See also
    1. Device Storage API
    2. DeviceStorage
    3. Properties
      1. default
      2. lowDiskSpace
      3. onchange
      4. storageName
    4. Methods
      1. add()
      2. addNamed()
      3. available()
      4. delete()
      5. enumerate()
      6. enumerateEditable()
      7. freeSpace()
      8. get()
      9. getEditable()
      10. usedSpace()
    5. Inheritance:
      1. EventTarget
    6. Events
      1. change
    7. Related pages for Device Storage API
      1. DeviceStorageChangeEvent
      2. Navigator.getDeviceStorage()
      3. Navigator.getDeviceStorages()

    © 2005-2016 Mozilla Developer Network and individual contributors.

    Content is available under these licenses.

    • About MDN
    • Terms
    • Privacy
    • Cookies
    • Contribute to the code

    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy