Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store data in FirefoxOS

Tags:

firefox-os

I'm trying to do some FirefoxOS apps, but I have not seen any easy way to store local data. I hear about IndexedDB, but it seems too complex. Is there any other alternative? If not, is there any easy tutorial about it?

I have considered to store and recove remote data (doing a croos domain request), but I'm having some issues with the permissions. Is there any tutorial about XHR for FirefoxOS?

Thanks.

like image 884
Cod1ngFree Avatar asked Apr 23 '13 15:04

Cod1ngFree


1 Answers

The best IndexDB doc I can found is Using IndexDB in MDN.

And there are plenty of default Firefox OS apps (gaia) such as gallery, browser using IndexDB. You can see how it works in real life.

Or you can use the more lightweight window.localStorage API, which works like a dictionary.

localStorage.setItem(key, value); 
localStorage.getItem(key);

EDIT: Note that localStorage is not recommend because its block the main thread. You should use gaia/shared/asyncStorage instead.

For XHR you can check Firefox-OS-Boilerplate-App for a working XHR demo

like image 123
gasolin Avatar answered Oct 25 '22 09:10

gasolin