Partager via


App data and IndexedDB

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

You can use Indexed Database, or IndexedDB, with Windows Runtime apps using JavaScript to store data for your app. Each app has a quota of 250MB. IndexedDB is a web standard for a database of records holding simple values and hierarchical objects. It is a low-level ISAM database API. Records consist of key-value pairs that may be indexed in a variety of ways. (For more technical details, see the W3C specification.)

You can use IndexedDB databases within Windows Runtime apps using JavaScript via asynchronous APIs that you reference from the page or in a web worker. Synchronous APIs are not supported. By default, only local context pages and web context pages that are declared in the ApplicationContentUriRules portion of the app’s package manifest can use IndexedDB. For info about how to use ApplicationContentUriRules to make a connection to web context pages, see How to link to external web pages. Other web context pages see the window.indexedDB and worker.indexedDB objects as undefined in JavaScript. You can make IndexedDB available for other websites via a meta tag, but be aware that this site can consume the app’s entire quota with no means for the app to purge this data. Only the user uninstalling the app can reclaim this space. Here's the meta tag that enables this behavior:

<meta name="ms-enable-external-database-usage" content="true"/>

Each app has a quota of 250MB. Among all apps on the device, the limit is 4% of the disk size or 20GB, whichever is smaller. For hard drives that are less than 30GB, the limit among all apps on the device is 375MB. Because of the overall quota among all apps, test your app to ensure it functions properly when it can store very little or even no data because other apps consume the overall quota. IndexedDB is primarily useful as a place to cache data from a web service for offline use.

Indexed Database API

IndexedDB sample