Description: | Use the chrome.storage API to store, retrieve, and track changes to user data. |
Availability: | Since Chrome 38. |
Permissions: | 'storage' |
Content Scripts: | Fully supported. Learn more |
Learn More: | Chrome Apps Office Hours: Chrome Storage APIs Chrome Apps Office Hours: Storage API Deep Dive |
storage.sync
).localStorage API
. localStorage API
stores data in strings).storage.managed
with a schema).storage.sync
: storage.local
: storage.sync
, the stored data will automatically be synced to any Chrome browser that the user is logged into, provided the user has sync enabled. storage.sync
will still work. In this case, it will behave identically to storage.local
. storage.managed
storage is read-only. chrome.storage
is not a big truck. It's a series of tubes. And if you don't understand, those tubes can be filled, and if they are filled when you put your message in, it gets in line, and it's going to be delayed by anyone that puts into that tube enormous amounts of material. onChanged
event. Whenever anything changes in storage, that event fires. The testament of sisters new devil uncensored. Here's sample code to listen for saved changes: Types | |
---|---|
StorageChange | |
StorageArea | |
Properties | |
sync | |
local | |
managed | |
Events | |
onChanged |
properties | ||
---|---|---|
any | (optional) oldValue | The old value of the item, if there was an old value. |
any | (optional) newValue | The new value of the item, if there is a new value. |
methods | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
get StorageArea.get(string or array of string or object keys, function callback) Gets one or more items from storage.
| ||||||||||||
getBytesInUse StorageArea.getBytesInUse(string or array of string keys, function callback) Gets the amount of space (in bytes) being used by one or more items.
| ||||||||||||
set StorageArea.set(object items, function callback) Sets multiple items.
| ||||||||||||
remove StorageArea.remove(string or array of string keys, function callback) Removes one or more items from storage.
| ||||||||||||
clear Removes all items from storage.
| ||||||||||||
events | ||||||||||||
addListener
|
StorageArea | chrome.storage.sync | Items in the sync storage area are synced using Chrome Sync.
| |||||||||||||||||||||
StorageArea | chrome.storage.local | Items in the local storage area are local to each machine.
| |||||||||||||||||||||
StorageArea | chrome.storage.managed | Items in the managed storage area are set by the domain administrator, and are read-only for the extension; trying to modify this namespace results in an error. |
chrome.storage.onChanged.addListener(function callback)
Parameters | ||||||||
---|---|---|---|---|---|---|---|---|
function | callback | The callback parameter should be a function that looks like this: function(object changes, string areaName) {..};
|