This topic describes the JavaScript (JS) APIs for the WVStorage cache. You can use these APIs to add, delete, and clear cached data for your H5 applications or miniapps.
WVStorage.setItem
This API is available only in Windvane for Android 1.0.3.4 and later.
Stores data in the local cache with a specified key.
Input parameters
[
string] key: The key for the cached data.[
string] value: The content to cache.
Callback parameters
Success callback parameters:
No callback parameters.
Failure callback parameters:
[
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 and later.
Retrieves the cached data for a specified key.
Input parameters
[
string] key: The specified key.
Callback parameters
Success callback parameters:
[
string] data: The content that corresponds to the key.
Failure callback parameters:
[
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 and later.
Deletes the cached data for a specified key.
Input parameters
[
string] key: The specified key.
Callback parameters
Success callback parameters:
No callback parameters.
Failure callback parameters:
[
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 and later.
Asynchronously clears the local data cache.
Input parameters
No input parameters.
Callback parameters
Success callback parameters:
No callback parameters.
Failure callback parameters:
[
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 and later.
Synchronously clears the local data cache.
Input parameters
No input parameters.
Callback parameters
Success callback parameters:
No callback parameters.
Failure callback parameters:
[
string] msg: The error message.
window.WindVane.call('WVStorage', 'clearStorageSync', {}, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});