Cross-platform SDK and HTML5 tools for mobile app development
X
 

Problem with LocalStorage on Windows Mobile

7 posts / 0 new
Last post
Asynadak
asynadak@gmail.com's picture
Offline
Joined: 8 Apr 2012
Posts:
Problem with LocalStorage on Windows Mobile

Hello,

I have developed an app and all works fine on android but there is a problem trying to run the app on windows mobile (emulator). Th problem seems to be with localStorage as any attemp to either get or set data does nothing!

The code below runs onLoad of the index.html and is supposed to check if the user is logged in or not to the system. To do so, checks a localStorage varable and creats the appropriate elements to put into a div.

document.addEventListener("deviceready", onDeviceReady2, false);

    function onDeviceReady2() {
        document.addEventListener("backbutton", onBackKeyDown2, false);
        //Check if logged in or not and show appropriate button
        alert (window.localStorage.getItem("isConnect"));
        if (window.localStorage.getItem("isConnect") == "true") {
            document.getElementById("connectionButton").innerHTML =    "Show Log out button";
        } else {
            document.getElementById("connectionButton").innerHTML =    "Show Log in button";
        }
    }

The alert is just for testing and while running shows nothing! When I put alert("Something"); works fine, but anything with LocalStorage seems not to be running.

Do you have any idea why this is happening (while everything runs smoothely on android)? Do I have to enable something in order to have localstorage on windows mobile?

Thanks in advance for your time and your help.

Asynadak
asynadak@gmail.com's picture
Offline
Joined: 8 Apr 2012
Posts:
Hello again, I am still stuck

Hello again, I am still stuck on this thing with windows phone and localStorage. While on Android, Opera, Chrome and Firefox everything runs as it should, on windows mobile I keep getting "Unable to get value of the property "isConnect": object is null or undefined.

While searching around, I found plenty of posts that people managed to use localStorage on windows phone either using phonegap or mosync.

So, since the code seems to be correct, is there anything that I could check on the emulator for example?

Thank you in advance for your time and your help. I really appriciate it.

Iraklis Rossis
Iraklis Rossis's picture
Offline
Mobile Archmage
Joined: 3 Aug 2011
Posts:
To be honest I have only been

To be honest I have only been using the File API (even on Android), so I have no idea about the WP7 one. Maybe an OS update would fix it?

Iraklis Rossis
Iraklis Rossis's picture
Offline
Mobile Archmage
Joined: 3 Aug 2011
Posts:
That's an HTML5 feature and

That's an HTML5 feature and it's going to be as supported as each platform allows it.

Since you are coding in MoSync, may I suggest using our File API instead?

Asynadak
asynadak@gmail.com's picture
Offline
Joined: 8 Apr 2012
Posts:
In the beginning I was

In the beginning I was working with the file API, but android had a difficult time with it (!) and couldn't create the file system. Reading the file was done, but it was doing nothing when it was to write it. So, I decided to implement it with LocalStorage.

According to this http://www.mosync.com/files/imports/doxygen/latest/html5/localstorage.md.html#localStorage windows phone should support LocalStorage. Additionally, I have seen a lot of examples in other forums (or in this) that people build something in WP with LocalStorage!

So, I was wondering wethere this is a WP problem or I am doing something wrong!

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:
Do you mean Windows Phone?

Do you mean Windows Phone?  Windows Mobile isn't supported for HTML apps (but Windows Phone is).

I'll have a look into this.  We've got a lot of updates for Windows Phone in the new version (3.1) so I'll find out if there is a fix in there.

Asynadak
asynadak@gmail.com's picture
Offline
Joined: 8 Apr 2012
Posts:
Yes, I meant Windows Phone,

Yes, I meant Windows Phone, sorry! When is going to be available the new version?

Login or register to post comments