Chrome storage for storing and updating the array

Is it possible to store an array in chrome storage synchronization and retrieve them?

var uarray = [abc,def,ghi]; 

Is it possible to update a stored array in storage?

 var tobeadded = jkl; uarray.push(tobeadded); 

it was the syntax in the documentation

 chrome.storage.sync.set({'value': theValue}, function() { // Notify that we saved. message('Settings saved'); }); 

To expand bookmarks, you must save the bookmark identifier and get them for internal search and materials based on it. The bookmark requires periodic updating of the identifier in the repository.

Thanks!!

+6
source share
1 answer

You can read existing values, add a new value and save back.

The following code sample should allow you to add newArrEntry to an existing array stored in chrome.storage.sync

 chrome.storage.sync.get(["storagekey"], function(result) { var array = result[storagekey]?result[storagekey]:[]; array.unshift(newArrEntry); var jsonObj = {}; jsonObj[storagekey] = array; chrome.storage.sync.set(jsonObj, function() { console.log("Saved a new array item"); }); }); 
+3
source

All Articles