Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap iOS 5.1 and localStorage

I was using localstorage for save one value in my App, that works with PhoneGap, but when Apple has released the new iOS 5.1, my App now doesn't save the value.

Does anybody know how to solve this problem?

Thank you very much!!!

Edit: I put the code I was using:

window.localStorage.setItem("login", $('#login').val());

I use it for save the value, and I use it for read the value:

function onDeviceReady() {
    var login = window.localStorage.getItem("login");

    if (login != null) {
        $('#login').val(login);
    }
}

But when I close the App, the values are not saved.

like image 702
chemitaxis Avatar asked Mar 12 '12 09:03

chemitaxis


People also ask

What is the best way to store unlimited data for PhoneGap?

SQLite is essentially the only way to persistently store unlimited data for PhoneGap applications, however other options I will cover in the rest of this post can also be made persistent and have unlimited data storage by using SQLite as a backend. Web SQL

How do I access local storage data in PHP?

varsomeSetting= localStorage.getItem('someSetting'); This is the native way to set and retrieve local storage data, but some frameworks have their own inbuilt ways to access local storage. One important thing to keep in mind when using local storage is that it can only store strings.

Is local storage a viable option?

Local storage gets a bit of a bad wrap, and is generally considered to be unreliable. I think the browsers local storage can be a viable option and it is reasonably stable and reliable, but, it is possible for the data to be wiped, which means for a lot of applications it's not going to be a great option.

When should I use local storage for my website?

One example of where local storage might be a suitable option is if you wanted to store something like a temporary session token. This would allow you to create a "Remember Me" type feature, but if the data is lost it's not really a big deal because the user will just need to enter in their username and password again.


1 Answers

There was a large thread in the phonegap group that talked about this problem. Basically its because they now treat localStorage as a temp item which can be deleted at any point. Never fear there are very smart people at work!

here's the thread - https://groups.google.com/forum/?fromgroups#!topic/phonegap/RJC2qA9sDnw

here's the code - http://pastebin.com/5881768B

like image 60
Drew Dahlman Avatar answered Oct 06 '22 00:10

Drew Dahlman