Revision 434585 of DeviceStorageChangeEvent

  • Revision slug: Web/API/DeviceStorageChangeEvent
  • Revision title: DeviceStorageChangeEvent
  • Revision id: 434585
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ domref() }}

{{ non-standard_header() }}

{{ B2GOnlyHeader2('privileged') }}

Summary

The DeviceStorageChangeEvent provides information about any change made to a file inside a given storage area. It extend the {{domxref("Event")}} interface.

The {{event("change")}} event is triggered each time a file is created, modified or deleted from the device storage system.

Properties

{{domxref("DeviceStorageChangeEvent.path")}} {{readonlyinline}}
A string giving the full path of the file affected by the change.
{{domxref("DeviceStorageChangeEvent.reason")}} {{readonlyinline}}
A string giving the reason of the change. Possible values are created, modified or deleted.

Example

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

sdcard.addEventListener("change", function (event) {
  var reason = event.reason;
  var path   = event.path;

  console.log('The file "' + path + '" has been ' + reason);
});

Specification

Not part of any specification.

See also

  • {{domxref("window.navigator.getDeviceStorage()","navigator.getDeviceStorage()")}}
  • {{domxref("DeviceStorage")}}
  • Device Storage API

Revision Source

<p>{{ domref() }}</p>
<p>{{ non-standard_header() }}</p>
<p>{{ B2GOnlyHeader2('privileged') }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>DeviceStorageChangeEvent</code> provides information about any change made to a file inside a given storage area. It extend the {{domxref("Event")}} interface.</p>
<p>The {{event("change")}} event is triggered each time a file is created, modified or deleted from the device storage system.</p>
<h2 id="Properties">Properties</h2>
<dl>
  <dt>
    {{domxref("DeviceStorageChangeEvent.path")}} {{readonlyinline}}</dt>
  <dd>
    A string giving the full path of the file affected by the change.</dd>
  <dt>
    {{domxref("DeviceStorageChangeEvent.reason")}} {{readonlyinline}}</dt>
  <dd>
    A string giving the reason of the change. Possible values are <code>created</code>, <code>modified</code> or <code>deleted</code>.</dd>
</dl>
<h2 id="Example">Example</h2>
<pre class="brush: js">
<code class="language-js">var sdcard = navigator.getDeviceStorage('sdcard');

sdcard.addEventListener("change", function (event) {
  var reason = event.reason;
  var path   = event.path;

  console.log('The file "' + path + '" has been ' + reason);
});</code></pre>
<h2 id="Specification" name="Specification">Specification</h2>
<p>Not part of any specification.</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{domxref("window.navigator.getDeviceStorage()","navigator.getDeviceStorage()")}}</li>
  <li>{{domxref("DeviceStorage")}}</li>
  <li><a href="/en-US/docs/WebAPI/Device_Storage" title="/en-US/docs/WebAPI/Device_Storage">Device Storage API</a></li>
</ul>
Revert to this revision