anon
anon

Reputation: 1117

How persistent is IndexedDB in a Chrome App

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.

Upvotes: 8

Views: 3733

Answers (2)

gzc
gzc

Reputation: 8639

If you ask for the unlimitedStorage permission in the manifest file for an chrome app or extension, the storage space is as large as the available space on the hard drive.In this case, you app won't exceed limit size.

see chrome app unlimited storage

Upvotes: 0

mmocny
mmocny

Reputation: 8855

Regarding IndexedDB:

  1. 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).

  2. Chrome apps sync across devices, but IndexedDB storage does not. chrome.storage.sync does (but is more like a localStorage replacement than IndexedDB replacement).

  3. 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.

Upvotes: 2

Related Questions