Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal access exception with LocalStorage on Android Gingerbread

I made an Android/Phonegap app, and it is running fine on all devices with several android OS versions, except on some Gingerbread (2.3) phones. I am using Phonegap 1.9.

Debugging the code, I realized an illegal access exception on Javascript, every time I use the HTML5 localStorage.getItem() and localStorage.setItem() methods.

How can I enable the localStorage features on those Android devices?

like image 836
Gabriel Mendez Avatar asked Oct 11 '12 18:10

Gabriel Mendez


1 Answers

The illegal exception was caused by JSON.parse() methods when the .getItem() returns null. Just be careful to validate it. Android 2.3, HTML5 localStorage and Phonegap are working perfectly now.

like image 100
Gabriel Mendez Avatar answered Nov 18 '22 10:11

Gabriel Mendez