I'd like to keep data on user's mobile with localStorage. My app is build with phonegap.
function check_connection()
{
var id = window.localStorage.getItem("id");
if(id != null)
// some code
console.log(id);
}
When I do this code after window.localStorage.setItem("id", "value");
, I get "value", but if I exit the application and run it again, I get "null".
document.addEventListener("deviceready", main, true);
function main()
{
check_connection();
}
The exit seems to clear the localStorage object.
Any idea ?
EDIT : The data is persistent when I quit the app by pressing back button, but when I kill the app from recent apps, the data is cleared. What is the problem ?
are you calling somewhere window.localStorage.clear();?
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