<?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 The localStorage API is not a in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004539#M31590</link>
    <description>&lt;P&gt;The localStorage API is not a Cordova or XDK feature, it is an HTML5 API. Thus, its behavior is governed by the "webview" on the target device, not the XDK or Cordova. This is similar to saying, its behavior depends on the version of the browser you're running in. As such, it is not very reliable and hard to characterize over a wide variety of devices.&lt;/P&gt;

&lt;P&gt;I suspect that the reason some localStorage values disappear when you "kill" the app is because the webview is not getting the opportunity to flush it's cache and store your new values in a place where they can be reread upon startup. When you "kill" an Android app (as in, swipe it from the recently run list of apps) the Android OS does not give the app an "about to die" event. It is killed immediately, so any cleanup that an app (in this case, the webview runtime) might do before being closed does not happen. It's similar to pulling the plug on your desktop computer while an app is running, if that app did not insure that it's local data was stored to disk before the plug was pulled, your data is gone.&lt;/P&gt;

&lt;P&gt;I highly recommend you use the SQLite plugin, even if you only need storage for a few items. This will use native storage. Or, use the File plugin to store some information in a local native file. This way, you have control over when any local data is stored to a file.&lt;/P&gt;</description>
    <pubDate>Sun, 13 Dec 2015 23:39:00 GMT</pubDate>
    <dc:creator>PaulF_IntelCorp</dc:creator>
    <dc:date>2015-12-13T23:39:00Z</dc:date>
    <item>
      <title>LocalStorage Values lost once app is killed</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004531#M31582</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I'm using LocalStorage to store some app configuration values which disappear once the app is killed.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I have tried window.localstorage.setItem and local storage.setItem both are accepted. I understood localstorage.setItem was the cordova version and persisted across app restarts.&lt;/P&gt;

&lt;P&gt;Interestingly I have an old app compiled as plain HTML5 app on XDK version 1726 and I use window.localstorage.setItem and those values persist through an app restart.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2015 15:16:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004531#M31582</guid>
      <dc:creator>Nick_F_2</dc:creator>
      <dc:date>2015-04-01T15:16:12Z</dc:date>
    </item>
    <item>
      <title>Work fine in emulator. I can</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004532#M31583</link>
      <description>&lt;P&gt;Work fine in emulator. I can load another projects run that in the emulator and local storage values persist across restarts of XDK and moving between projects.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2015 15:22:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004532#M31583</guid>
      <dc:creator>Nick_F_2</dc:creator>
      <dc:date>2015-04-01T15:22:25Z</dc:date>
    </item>
    <item>
      <title>Is this through the App</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004533#M31584</link>
      <description>&lt;P&gt;Is this through the App Preview app or an actual build? &amp;nbsp;What device are you on? The more information, more likely it is someone can help.&lt;/P&gt;

&lt;P&gt;The only thing I can think of is that maybe your root is changing between launches. &amp;nbsp;To check if that's the case, alert the value intel.xdk.webRoot. &amp;nbsp;I don't think the webRoot is supposed to change very much, but it could be responsible. &amp;nbsp;Also, there have been quite a few topics about the Intel XDK plugins not working (and thus causing errors), so make sure its not that the data is just never getting stored because of an error.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2015 21:37:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004533#M31584</guid>
      <dc:creator>James_H_1</dc:creator>
      <dc:date>2015-04-01T21:37:03Z</dc:date>
    </item>
    <item>
      <title>I think you can skip the</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004534#M31585</link>
      <description>&lt;P&gt;I think you can skip the window. This works for me without issues:&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;localStorage.flipswitch0 = "1";&lt;/PRE&gt;

&lt;P&gt;If you need to make the name variable do this:&lt;/P&gt;

&lt;PRE class="brush:jscript;"&gt;localStorage[allScenarios.categories[index].shortname+"Purchased"] == 1;&lt;/PRE&gt;

&lt;P&gt;where allScenarios is an object and index is a variable.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
	K'shin&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2015 23:51:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004534#M31585</guid>
      <dc:creator>K_shin</dc:creator>
      <dc:date>2015-04-01T23:51:20Z</dc:date>
    </item>
    <item>
      <title>Hi</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004535#M31586</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;It is the actual build is not loading the localStorage values. In the emulator it is fine. This is affecting iOS not Android&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2015 15:07:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004535#M31586</guid>
      <dc:creator>Nick_F_2</dc:creator>
      <dc:date>2015-04-02T15:07:50Z</dc:date>
    </item>
    <item>
      <title>OK</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004536#M31587</link>
      <description>&lt;P&gt;OK&lt;/P&gt;

&lt;P&gt;Found the issue, I had an AppMobi.device.hideStatusBar(); under the document ready function and this was causing the failure under IOS but not Android. Which brings b=me to another issue, I cannot get the HideStatus to work in the App, under the emulator it works fine.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2015 15:25:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004536#M31587</guid>
      <dc:creator>Nick_F_2</dc:creator>
      <dc:date>2015-04-02T15:25:44Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004537#M31588</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
	&lt;BR /&gt;
	I have the same problem.&lt;BR /&gt;
	&lt;BR /&gt;
	I use &lt;STRONG&gt;HTML5 + Cordova Blank&lt;/STRONG&gt; project plus &lt;STRONG&gt;AngularJS&lt;/STRONG&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 &lt;STRONG&gt;1995&lt;/STRONG&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;STRONG&gt;Here are the code snippets I use:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;this.getUserToken = function () {&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&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&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&gt;Any help would be super appreciated.&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2015 07:03:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004537#M31588</guid>
      <dc:creator>Alper_B_</dc:creator>
      <dc:date>2015-05-20T07:03:38Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004538#M31589</link>
      <description>&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Hello,&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;I have the same problem.&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;I use&amp;nbsp;&lt;SPAN style="font-weight: 700;"&gt;HTML5 + Cordova Blank&lt;/SPAN&gt;&amp;nbsp;project . &amp;nbsp;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;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;I have tried both in emulator and on device. The result is same.&amp;nbsp;XDK version &lt;B&gt;2727&lt;/B&gt;.&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;I am using &amp;nbsp;localStorage.&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;SPAN style="line-height: 1.5;"&gt;Any help would be super appreciated.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 05:10:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004538#M31589</guid>
      <dc:creator>Bhavya_A_</dc:creator>
      <dc:date>2015-12-10T05:10:16Z</dc:date>
    </item>
    <item>
      <title>The localStorage API is not a</title>
      <link>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004539#M31590</link>
      <description>&lt;P&gt;The localStorage API is not a Cordova or XDK feature, it is an HTML5 API. Thus, its behavior is governed by the "webview" on the target device, not the XDK or Cordova. This is similar to saying, its behavior depends on the version of the browser you're running in. As such, it is not very reliable and hard to characterize over a wide variety of devices.&lt;/P&gt;

&lt;P&gt;I suspect that the reason some localStorage values disappear when you "kill" the app is because the webview is not getting the opportunity to flush it's cache and store your new values in a place where they can be reread upon startup. When you "kill" an Android app (as in, swipe it from the recently run list of apps) the Android OS does not give the app an "about to die" event. It is killed immediately, so any cleanup that an app (in this case, the webview runtime) might do before being closed does not happen. It's similar to pulling the plug on your desktop computer while an app is running, if that app did not insure that it's local data was stored to disk before the plug was pulled, your data is gone.&lt;/P&gt;

&lt;P&gt;I highly recommend you use the SQLite plugin, even if you only need storage for a few items. This will use native storage. Or, use the File plugin to store some information in a local native file. This way, you have control over when any local data is stored to a file.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Dec 2015 23:39:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/LocalStorage-Values-lost-once-app-is-killed/m-p/1004539#M31590</guid>
      <dc:creator>PaulF_IntelCorp</dc:creator>
      <dc:date>2015-12-13T23:39:00Z</dc:date>
    </item>
  </channel>
</rss>

