<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic I tried just putting this in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008690#M33097</link>
    <description>&lt;P&gt;I tried just putting this basic code in an init-app.js:&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;    var thisisit = localStorage.getItem('thing');
    
    alert(thisisit);
    
    localStorage.setItem('thing','tostore');&lt;/PRE&gt;

&lt;P&gt;and it works fine on emulator and device debug. &amp;nbsp;(first time null displayed, second time 'tostore'. &amp;nbsp;maybe double check you're not trying to store a null json token value?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 May 2015 18:39:45 GMT</pubDate>
    <dc:creator>David_B_22</dc:creator>
    <dc:date>2015-05-20T18:39:45Z</dc:date>
    <item>
      <title>localStorage is lost after restart</title>
      <link>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008689#M33096</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
	&lt;BR /&gt;
	As a seperate post I'd like to send here, as it is a bit different than the other thread.&lt;/P&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;I use&amp;nbsp;&lt;SPAN style="font-weight: 700;"&gt;HTML5 + Cordova Blank&lt;/SPAN&gt;&amp;nbsp;project plus&amp;nbsp;&lt;SPAN style="font-weight: 700;"&gt;AngularJS&lt;/SPAN&gt;. Without Cordova build the local storage functionality works fine. However, with the Cordova build, when I set a value at localStorage it works, but when I restart the APP, the values within the LocalStorage is lost.&lt;BR /&gt;
	&lt;BR /&gt;
	I have tried both in emulator and on device. The result is same.&amp;nbsp;XDK version&amp;nbsp;&lt;SPAN style="font-weight: 700;"&gt;1995&lt;/SPAN&gt;.&amp;nbsp;&lt;BR /&gt;
	&lt;BR /&gt;
	I have tried both window.localStorage and just localStorage.&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;SPAN style="font-weight: 700;"&gt;Here are the code snippets I use:&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;this.getUserToken = function () {&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return JSON.parse(localStorage.getItem("userToken"));&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (err)&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alert(err.message);&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return null;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; };&lt;/P&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;&amp;nbsp; &amp;nbsp; this.setUserToken = function (token) {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return localStorage.setItem("userToken", JSON.stringify(token));&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; };&lt;/P&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;Any help would be super appreciated.&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2015 07:07:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008689#M33096</guid>
      <dc:creator>Alper_B_</dc:creator>
      <dc:date>2015-05-20T07:07:35Z</dc:date>
    </item>
    <item>
      <title>I tried just putting this</title>
      <link>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008690#M33097</link>
      <description>&lt;P&gt;I tried just putting this basic code in an init-app.js:&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;    var thisisit = localStorage.getItem('thing');
    
    alert(thisisit);
    
    localStorage.setItem('thing','tostore');&lt;/PRE&gt;

&lt;P&gt;and it works fine on emulator and device debug. &amp;nbsp;(first time null displayed, second time 'tostore'. &amp;nbsp;maybe double check you're not trying to store a null json token value?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2015 18:39:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008690#M33097</guid>
      <dc:creator>David_B_22</dc:creator>
      <dc:date>2015-05-20T18:39:45Z</dc:date>
    </item>
    <item>
      <title>Hi David,</title>
      <link>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008691#M33098</link>
      <description>&lt;P&gt;Hi David,&lt;BR /&gt;
	&lt;BR /&gt;
	Thank you for the prompt reply.&lt;BR /&gt;
	&lt;BR /&gt;
	Yes, I'm sure that I'm not writing null. Because right after writing, i'm displaying the latest status of localStorage and it shows the right content. Right after I restart the app, the localstorage returns null again. Code logic is very simple, I tested carefully many times.&lt;BR /&gt;
	&lt;BR /&gt;
	Interesting is, intel.xdk.cache.setCookie and getCookie also fails. Now I'm taking a shot using Cordova FileSystem tor read and write my content, because I'm under deadline pressure.&amp;nbsp;&lt;BR /&gt;
	&lt;BR /&gt;
	Best regards,&lt;BR /&gt;
	Alper&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2015 19:04:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008691#M33098</guid>
      <dc:creator>Alper_B_</dc:creator>
      <dc:date>2015-05-20T19:04:36Z</dc:date>
    </item>
    <item>
      <title>To make any of the intel.xdk</title>
      <link>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008692#M33099</link>
      <description>&lt;P&gt;To make any of the intel.xdk namespace functions work make sure you've got a reference to intelxdk.js in your index.html file (before the reference to cordova.js) and have selected the appropriate plugin from the plugins list.&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2015 22:23:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008692#M33099</guid>
      <dc:creator>PaulF_IntelCorp</dc:creator>
      <dc:date>2015-05-22T22:23:56Z</dc:date>
    </item>
    <item>
      <title>Hi Alper,</title>
      <link>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008693#M33100</link>
      <description>&lt;P&gt;Hi Alper,&lt;/P&gt;

&lt;P&gt;I hope you have managed to resolve your issues. If you are still struggling, here is my 2 cents..&lt;BR /&gt;
	I had some troubles with localStorage long time ago, but it turned out it was my fault - even I was using very simple code.&lt;BR /&gt;
	It had to do with me actually deleting the object value unintentionally by using references and not copies of objects where I should not.&lt;BR /&gt;
	It might not be a case, but can be cause of trouble sometimes, and is easily missed.&lt;/P&gt;

&lt;P&gt;Second, a hint - are you using the debug windows in your XDK Emultor? - It can show the content of localStorage so you can follow what and when is stored/deleted.&lt;/P&gt;

&lt;P&gt;In my last project, I was using AngularJS and ngStorage (actually a wrapper for localStorage, and it is working fine in XDK - tested before the latest 1995 update) on both Emulator and Device (using Crosswalk).&lt;/P&gt;

&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2015 10:51:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008693#M33100</guid>
      <dc:creator>Dragan_T_</dc:creator>
      <dc:date>2015-05-26T10:51:53Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008694#M33101</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;You guys were all right. That was a programming mistake from us and nothing to do with XDK.&lt;BR /&gt;
	&lt;BR /&gt;
	Thanks a lot!&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2015 20:12:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/localStorage-is-lost-after-restart/m-p/1008694#M33101</guid>
      <dc:creator>Alper_B_</dc:creator>
      <dc:date>2015-09-22T20:12:36Z</dc:date>
    </item>
  </channel>
</rss>

