I have stored some data in local storage. I want to retrieve all local storage details. This is my local storage saving code. This below code saving data usr data
var user_arr=new Array();
function getData()
{
for (var i=1; i<=3; i++)
{
var userran=parseInt((Math.random() * (278 - 0+ 1)), 10) + 0;
localStorage['userCard']=user_arr.push(cards[userran]);
}
alert(localStorage['userCard']);
window.location = 'file:///android_asset/www/game.html';
}
above code works when clicking the button,when I am alerting alert( localStorage['userCard']);
it gives the integer value in alert box.
Intially I stored this value in localstorage
I want to get all details in local storage. Can anybody reply how to retrieve this?
hi i getting the data from local storage,my initial local storage data is and it contains 3 cricket player details. and when i alerts the first card using alert the first card details it shows only alert(userCard[0]); it gives only the N as output, how to get all data.
var userCard=[["Nixon", "McLean", "West Indies", 45, 314, 0, 1, "12.07", "37.58", 46, 3, 21, 8, "img/cards/7RBKWQPJAG_NixonMcLean.jpg", 1], ["Brian", "McMillan", "South Africa", 78, 841, 1, 0, "23.36", "36.98", 70, 4, 32, 43, "img/cards/Y9U5UKA60O_BrianMcMillan.jpg", 2], ["Craig", "McMillan", "New Zealand", 197, 4707, 3, 28, "28.18", "35.04", 49, 3, 20, 44, "img/cards/WE0NUNG80C_CraigMcMillan.jpg", 3]]
Just type localStorage
in your console, you will get all the data stored in local storage.
Since it is a json type dictionary, you can simply iterate through all the elements like this:
local = localStorage;
for (var key in local) {
console.log(key);
//Do something with key, access value by local[key]
}
This will give you all the keys in dict in console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With