Developing an offline Chrome App using IndexedDB as storage and have following questions:
1.Other than user opening the console in my app and clearing the indexedDB is there any other way I have to worry about the IndexedDB data getting lost?
2.Since chrome apps are now portable to ios and android using cordova, do the unlimitedStorage and FileSystem Apis also work on these platforms? So I can use them to store my indexed db and use filesystem to keep backup of indexeddb.
IndexedDB data belong to a type of temporary. So these data can be wiped out at any time. These data size/lifetime are managed by very new Quota Management API. In the future, IndexedDB could possibly used persistance type (not likely and not good idea too).
Note: After introducing Storage API, the "permanent" folder can be considered obsolete; the "permanent" folder only stores IndexedDB persistent-type databases.
More specifically, IndexedDB data is stored in the browser profile folder.
In theory, all you need to do to delete an IndexedDB in Chrome is: In Chrome, go to Options > Under the Hood > Content Settings > All cookies and Site Data > find the domain where you created the IndexedDB. Hit either the "X" or click "Indexed Database" > Remove.
Here is the definition of IndexedDB on MDN: IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high performance searches of this data.
This guide shows you how to use Chrome DevTools to view and change IndexedDB data. It assumes you're familiar with DevTools. If not, see Get started. It also assumes you're familiar with IndexedDB. If not, see Using IndexedDB. Click the Application tab to open the Application panel. Expand the IndexedDB menu to see which databases are available.
IndexedDB values in the Application panel do not update in real-time. Click Refresh when viewing an object store to refresh its data, or view a database and click Refresh database to refresh all data. Figure 6. Viewing a database IndexedDB keys and values are not editable from the Application panel.
You get a large storage for storing complex structures, but will have to deal with schema migrations and more implementation complexity. For very simple use cases you might want to consider localStorage, sessionStorage or cookies instead. In this tutorial we will build a simple javascript (ES6) database class using indexedDB.
Regarding IndexedDB
:
There are limits on size, if your app exceeds them, data will be 'lost'. (I'm not actually sure if unlimitedStorage
applies only to FS or also to IDB -- but either way the disk has limits too).
Chrome apps sync across devices, but IndexedDB storage does not. chrome.storage.sync
does (but is more like a localStorage
replacement than IndexedDB
replacement).
I cannot seem to be able to find details on it now, but I remember hearing about an uncommon bug that lead some apps (only when going through a particular type of upgrade) to potentially lose IndexedDB data. This really isn't the norm, so I wouldn't worry about it. But for completeness it is another possible way to lose data.
Regarding Chrome Apps for Mobile using Cordova fileSystems:
We do support chrome.fileSystem
(as well as the HTML5 fileSystem), however IndexedDB
is not natively supported in iOS WebView nor Android WebView prior to KitKat. There is a cordova
plugin you can install to get it to work (and I have used this myself), but I am not sure how trustworthy/easy it would be to backup and restore the database itself (why do you want to?).
Edit: Chrome Apps for Mobile do also support chrome.storage.local
but do not yet support sync.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With