window.navigator.getDeviceStorage

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

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

Summary

The getDeviceStorage method is used to access some storage area available on the device.

This method gives access to a unified view of all the storage area of a given type. For example, if the sdcard storage area is requested on a device with two SDCards available, the resulting DeviceStorage object gives access to the files available on both cards at the same time. To access a single storage area, it's necessary to use the getDeviceStorages method which returns an Array of DeviceStorage objects, one per physical storage area.

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

  var instanceOfDeviceStorage = navigator.getDeviceStorage(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 SDCard.
  • videos: This is the storage area where videos are stored.

Returns

This method returns a DeviceStorage object that can be used to manage files on the associated storage area.

Example

var sdcard = navigator.getDeviceStorage("sdcard");

Specification

Not part of any specification.

See also

Document Tags and Contributors

 Last updated by: teoli,