Hi guys,
I have problems with the LocalStorage. I just want to store some favorites. Here’s my code:
.factory('Database', [function(){
var myFactory = {};
//local storage
var ls = window.localStorage;
var db = {};
db.addFavorite = function (id){
ls.setItem(id,true);
};
db.removeFavorite = function (id){
ls.removeItem(id);
};
db.isFavorite = function (id){
var bool = ls.getItem(id);
if (bool != true) {bool = false};
return bool;
};
return myFactory;
}]);
Everything works fine (especially in Chrome), but not on device (Galaxy S3). When the app is active, it works, but when I close it via taskmanager, the LocalStorage is cleared.
Any ideas?
Thanks for your help.
P.S.: I tried cookies, LocalStorage, PhoneGap Storage and the ngCordova SQLite plugin (https://github.com/driftyco/ng-cordova). Nothing worked.