Use the WVStorage JavaScript APIs to store, retrieve, remove, and clear cached data in your HTML5 apps and miniapps.
WVStorage is part of the WindVane JavaScript bridge and provides persistent key-value storage for local caching. All APIs follow the same call pattern:
window.WindVane.call('WVStorage', '<method>', params, successCallback, failureCallback)
WVStorage.setItem
This API is available only in WindVane for Android 1.0.3.4 or later.
WVStorage.setItem(key: string, value: string)
Stores a string value in the local cache under the specified key. If the key already exists, its value is overwritten.
Input parameters
[
string] key (required): The key for the cache entry.[
string] value (required): The value to store.
Callback parameters
On success:
No callback parameters.
On failure:
[
string] msg: The error message.
var params = {
key: 'key',
value: 'value'
};
window.WindVane.call('WVStorage', 'setItem', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVStorage.getItem
This API is available only in WindVane for Android 1.0.3.4 or later.
WVStorage.getItem(key: string): string
Retrieves the cached value for the specified key.
Input parameters
[
string] key (required): The key of the cache entry.
Callback parameters
On success:
[
string] data: The value associated with the key.
On failure:
[
string] msg: The error message.
var params = {
key: 'key'
};
window.WindVane.call('WVStorage', 'getItem', params, function(e) {
alert('success: ' + JSON.stringify(e));
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVStorage.removeItem
This API is available only in WindVane for Android 1.0.3.4 or later.
WVStorage.removeItem(key: string)
Removes the cache entry for the specified key.
Input parameters
[
string] key (required): The key of the cache entry to remove.
Callback parameters
On success:
No callback parameters.
On failure:
[
string] msg: The error message.
var params = {
key: 'key'
};
window.WindVane.call('WVStorage', 'removeItem', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVStorage.clearStorage
This API is available only in WindVane for Android 1.0.3.4 or later.
WVStorage.clearStorage()
Clears all entries from the local cache asynchronously. Use this method to avoid blocking the app during cache operations.
Input parameters
No input parameters.
Callback parameters
On success:
No callback parameters.
On failure:
[
string] msg: The error message.
window.WindVane.call('WVStorage', 'clearStorage', {}, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVStorage.clearStorageSync
This API is available only in WindVane for Android 1.0.3.4 or later.
WVStorage.clearStorageSync()
Clears all entries from the local cache synchronously. The call blocks until the operation completes.
Input parameters
No input parameters.
Callback parameters
On success:
No callback parameters.
On failure:
[
string] msg: The error message.
window.WindVane.call('WVStorage', 'clearStorageSync', {}, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});