I am working on an Android project that relies on WebView to view several HTML pages stored on a device and send web view inputs when it is needed to store them in a database.
Each page contains controls related to jQuery towards the previous / next pages, each page contains inputs of different types (flags, text fields, etc.).
The final page contains Submit buttons that use JSInterface to save the results inside SQLite DB.
Another button (on the custom top navigation bar) offers the same system.
The results can be changed by accessing the first page with all the saved entries, the jQuery system will fill in the corresponding entries.
For more details, I use SDK 19 and compile with 4.4.2 , but I worked with SDK 15 > and compile in 4.2.2 , where I had no problem.
If someone needs to see what is being done on a simplified system, check out JSBin .
Problem
I use SessionStorage to store input between pages that I used to work with cookies, but they became unreliable when there were more than 150 key / value pairs.
My problem is that on some devices, SessionStorage disappears between pages.
Test protocol
1st case - Only the first page remains
If I stay only on the first page, fill in the entries, then send the results, everything will be fine. Returning for modification offers me a completely filled first page.
The second case - moving between pages
After filling out page 1, I go to page 2 and fill in the new entries, and then move between the pages to see if the entries on each individual page are lost. Everything is in place, but if I send the results, only the current page entries will be transferred.
Android Version Test Results
3.2 - Works
4.1.2 - Doesn't work
4.2.1 - Doesn't work
4.3 - Doesn't work
4.4.2 - Works
Proven Solutions
Insights
Switching from sessionStorage to localStorage did not help.
I found useful information about the versions of WebKit used by Android:
Android 3.2.1 uses a rather old version, but it works (v534.13)
Android , from 4.0 to 4.3 , share the same WebKit engine (v534.30)
Android 4.4 uses a completely new version (v537.36) that explains why it works.
Not one step to fix, but it gives a more accurate idea of ββthe problem and the device that it affects.
Decision
Since SDK 16, the new security setting was forced to prohibit Javascript code to access content from any source.
if(Build.VERSION.SDK_INT >= 16) { setting.setAllowUniversalAccessFromFileURLs(true); }
Kudos to ksasq for finding this!
[EDIT 02/18/2014]
After some testing, I pointed the problem to TargetSdkVersion, BuildTarget does not change anything.
It is set to 15 , WebStorage is working as intended.
If it is set to 16 or higher, WebStorage gets confused.