Languages

Menu
Sites
Language
How can i store data to the local storage of TIZEN mobile

Hi,

I am developing application in which i want to store data in local storage>how can i store data to local storage.

 

 

 

Please help me

 

 

Thanks and regards

Mohit Kumar

 

Responses

2 Replies
Marco Buettner

I prefer to store JSON in localStorage

store data (value) to specific key (save point)
function save(key, value) {
    localStorage.setItem(key, JSON.stringify(value));
}

restore data from specific key (save point)
function load(key) {
    return JSON.parse(localStorage.getItem(key)) || null;
}

 

Seoghyun Kang

Hello,

 

Please refer my code snippet .

- https://developer.tizen.org/community/code-snippet/web-code-snippet/how-getset-localstorage-value

 

/*******************************
*       HTML File
*******************************/

<input type="checkbox" id="checkbox1">checkbox</input>


/*******************************
*       Javascript File
*******************************/

// Set the LocalStorage value
var checkbox = document.getElementById("checkbox1");
localStorage.setItem("checkbox1", checkbox.checked);


// Get the LocalStorage value
var checked = JSON.parse(localStorage.getItem("checkbox1"));
document.getElementById("checkbox1").checked = checked;