Languages

Menu
Sites
Language
localStorage saves, but don't play data in the emulator

I need your help, I can not understand it myself.
I'm developing an application for TVs. To save some input, I use localStorage. I am writing on Java Script using AngularJs.

Running the application in the simulator, localStorage saved the information and, when closing the application and re-entering, the information is reproduced. Everything works perfectly!
The problem is that the same code does not work in the emulator. In localStorage, the information is saved, but when the application (or emulator) is closed and the application is re-entered, there is no information in localStorage, it is empty.
Why can there be?
Can, it is necessary to register any privilege in config.xml? Or do some additional emulator settings?
Html code:

<div id="container5"  data-ng-show="requirePinForCasting" >
  <p id="con10">
    <b>Pin code</b>
  </p>
  <div class="center">
  
  <p> <input id="con15" type="text"  maxlength="4" required placeholder="PIN" data-ng-model="pinCode" data-ng-change="pinChange()"></p>
  
    </div>
</div>

Script code:

window.angular.module('nuWireApp.SignUp').controller(
    'CastingCntrl',
    [
        '$scope',
        '$state', 
        function($scope, $state,) {
            
                         
          $scope.pinChange = function() {
          
           localStorage.setItem('pinCode-'+$scope.userId, '' + $scope.pinCode);
                          
          };
          
          $scope.pinCode = localStorage.getItem('pinCode-'+$scope.userId);
          
       
    } ]);

Responses

3 Replies
Armaan-Ul- Islam

I've tested the simple local storage code for testing purpose and it worked fine on my environment. Please inspect the same scenario in your workstation.

Environment:

Tizen Studio 2.5

Project Template: tv-4.0-> Basic UI

Emulator Platform: tv-4.0x86

 

index.html

<body>
  <div class=contents>
      <div style='margin:auto;'>
      	<button id=setBox>Set</button>
  		<button id=getBox>Get</button>
  	</div>
  </div>
</body>

main.js

var setbox = document.querySelector('#setBox');
setbox.addEventListener("click", function(){        
	localStorage.setItem("item_keyA", "valueB");
});

var getbox = document.querySelector('#getBox');
getbox.addEventListener("click", function(){    	
	var data = localStorage.getItem("item_keyA");
	alert(data);
});

Exited and restarted Emulator, but local Storage data is stored successfully.

Elena Iavorska

Thanks for your reply. Unfortunately, this does not work for me. This problem has not yet been resolved.

Armaan-Ul- Islam

Okay. Would you please create a new clean template project from the scratch and include the html, js codes I shared above?

Then run that template project on Emulator and let know the response.