how to override JAVAScript localStorage

+5 votes
13,192 views
asked Dec 13, 2012 in Objective C by admin (8,115 points)

hi 

   We develop html universal app  so we used cordova.  cordova having local storage for store some data in device

we don't need localStorage instead we plan to use coredataStorage(ios storage)..

so we plan to override the localStorage.  localStorage("key","value"); this call to the our overrided fuction.is there any 

way do this?

1 Answer

+1 vote
answered Dec 13, 2012 by codeg (2,600 points)
edited May 3 by admin

hi

 i hope this little bit of code solve your problem

Storage.prototype._setItem = Storage.prototype.setItem;

Storage.prototype.setItem = function(key, value)

{

  //do somthing here

}

Storage.prototype._getItem = Storage.prototype.getItem;

 Storage.prototype.getItem = function(key){

    // do somthing here

}

...