chrome.storage.local

333 views
Skip to first unread message

Nils Bantin

unread,
Oct 7, 2013, 11:18:04 AM10/7/13
to chromi...@chromium.org
Hello,

I have developed a game which saves the data in localStorage. Now I want the game as a Chrome packaged app but my code does not work. This is my code:

var results = [];
results[0] = 0;
results[1] = 1;
results[2] = 2;

chrome.storage.local.set({'results': results});//update data

chrome.storage.local.get('array', function (items) {//get data while starting the game
        results = items;
});

What is the mistake?

Renato Mangini

unread,
Oct 7, 2013, 11:37:03 AM10/7/13
to Nils Bantin, Chromium Apps

1) make sure you have requested "storage" permission in manifest.json
2) fix your code (fixes in bold):
chrome.storage.local.set({'results': results});//update data

chrome.storage.local.get('results', function (items) {//get data while starting the game
        results = items['results'];
});


Renato Mangini | Chrome Developer Programs Engineer | man...@google.com | +55 11 2395-8608


--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.

Nils Bantin

unread,
Oct 8, 2013, 8:21:11 AM10/8/13
to chromi...@chromium.org, Nils Bantin
Thank you. It works.
Reply all
Reply to author
Forward
0 new messages