언어 설정

Menu
Sites
Language
Wearable - localStorage is not persisted in emulator.

Hi experts,

I'm trying to develop a wearable app using the localStorage to store my settings.

I'm using tizen studio to launch my app in debug mode in the emulator.

I noticed when I first launch an app, I can store and read in the localstorage using localStorage.setItem and localStorage.getItem(); I can also see it in the developer console.

However once I launch the app from Tizen studio again (in debug mode), when I do a read (i.e. getItem), it reads nothing. I can also see in the developer console the local storage is empty.

I'm testing in wearable 4.0 circle x86 emulator.

I suspect every time I launch the app from Tizen studio the app.

This is really frustrating as the spec says localStorage will remain pass a session.

Please help.

Responses

3 댓글
André Reus

Hi Robert Tobor

In my case, I can getItem until i clean the project from Tizen Studio! I set an Item (Local Storage item) on button click listener.  Then i 

Debug As Tizen Web App and getItem for that key...i got the value. 

Code

 // Sample code
    var textbox = document.querySelector('.contents');
    textbox.addEventListener("click", function(){
        box = document.querySelector('#textbox');
    	localStorage.setItem("td2", "Basic");
    	box.innerHTML = box.innerHTML == "Basic" ? "Sample" : "Basic";
    	print();
    });
    
    
    function print(){
    	// retrieve item
  	  var data = localStorage.getItem("td1");
  	  var data2 = localStorage.getItem("td2");
  	  console.log(data);
  	  console.log(data2);
    };
    
    function init(){
    	localStorage.setItem("td1", "Test Hello");
    print();	
    	
    };
    
    init();

Log:

Test Hello
main.js:29 null
main.js:28 Test Hello
main.js:29 Basic
main.js:28 Test Hello
main.js:29 Basic
main.js:28 Test Hello
main.js:29 Basic

Only first time before setting the value is null. After setting the value from click, i Run / Debug the App again and again....i got the value Basic each time untill i clean the project. 

My Project Api : Tizen 3.0

Emulator: Tizen 3.0 

 

André Reus

Enabling Rapid Developement may solve your problem like me! Right click on your project, Click on Properties. From properties go Tizen Studio > Rapid Development...enable it. 

Marco Buettner

@Robert Normal behaviour because even your start "debug as" the app will "removed and installed" on the emulator and you will lost the datas. Restart the app on the emulator or turn of "rapid development" this should prevent the removing.