Navigator.getDeviceStorages()

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

Summary

The getDeviceStorages method is used to access individual storage areas available on the device. This method return an Array of DeviceStorage objects, one per physical storage area. Each storage area will have a name, retrievable using the .storageName attribute (see below).

Note: To be able to use a storage area, the application must declare it in its application manifest. For example, if the application wants to access the sdcard storage area, it must have the "device-storage:sdcard" permission in its manifest.

Syntax

JavaScript
var areas = navigator.getDeviceStorages(storageName);

Parameters

storageName
The name of the targeted storage area. Firefox OS supports the following areas:
  • apps: This storage area is used to store the user data needed by apps. As it is critical data, accessing this storage area requires some extra privileges and is available for certified applications only.
  • music: This is the storage area where music and sounds are stored.
  • pictures: This is the storage area where pictures are stored.
  • sdcard: This is the storage area that gives access to the device's SDCards.
  • videos: This is the storage area where videos are stored.

Returns

This method returns an Array of DeviceStorage objects that can be used to manage files on the associated physical storage area.

Example

JavaScript
var sdcards = navigator.getDeviceStorages("sdcard");

console.log("There are " + sdcards.length + " SDCards available.");

Specification

Not part of any specification.

See also

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/navigator/getdevicestorages

API B2G Device Storage Firefox OS Method Non-standard Reference