This API is available on Firefox OS for internal applications 仅。

摘要

navigator.getDataStores() method provides access to a list of the Data Store API data stores available on the device.

句法

navigator.getDataStores('contacts').then(function(stores) {
  // do something with the array of data stores in stores
});
					

参数

storeName

The name of the data store you want to return. An array is returned because there may be multiple data stores with the same name.

返回

A Promise object that will resolve with an array of DataStore 对象。

范例

navigator.getDataStores('contacts').then(function(stores) {
  stores[0].getLength().then(function(storeLength) {
    if(storeLength == 0) {
      for(i = 0; i < contactsInit.length; i++) {
        addContact(stores[0],contactsInit[i]);
      };
    } else {
      var cursor = stores[0].sync();
      runNextTask(cursor);
    }
  });
});
					

规范

规范 状态 注释
Data Store API 草案 The discussion concerning this API's creation happened in various Mozilla mailing lists and other places. A summary of the discussion and further pointers can be found on the Mozilla Wiki . For further feedback and questions, send mail to the dev-webapi mailing list.

浏览器兼容性

Supported in Firefox OS 1.0.1.

Available in web workers in Firefox OS 2.0.

另请参阅

元数据

  • 最后修改: