Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Development

Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

why window.local storage not work on android

can you please tell me why local storage will not work on android 2.3 version using phonegap technology..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>First Group</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<!--link href="style/scrollpanel.css" rel="stylesheet" type="text/css" /-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <script type="text/javascript" src="cordova-1.9.0.js"></script>
    <script type="text/javascript" src="script/soapclient.js"></script> 
    <script type="text/javascript" src="script/common.js"></script>

    <script type="text/javascript">
       document.addEventListener("deviceready", onDeviceReady, false);

        //Cordova is loaded and it is now safe to make calls Cordova methods

        function onDeviceReady() 

           // navigator.splashscreen.hide();

        function checkConnection() 
            var networkState = navigator.network.connection.type;

            var states = {};
            states[Connection.UNKNOWN]  = 'Unknown connection';
            states[Connection.ETHERNET] = 'Ethernet connection';
            states[Connection.WIFI]     = 'WiFi connection';
            states[Connection.CELL_2G]  = 'Cell 2G connection';
            states[Connection.CELL_3G]  = 'Cell 3G connection';
            states[Connection.CELL_4G]  = 'Cell 4G connection';
            states[Connection.NONE]     = 'No network connection';
            alert('Connection type: ' + states[networkState]);
            if(states[networkState]=="No network connection")
                alert("No Connection Available ");

           var stationList = new Array; 

        function GetStationCodes()
            var r = JSON.parse(window.localStorage.getItem("stations"))||[];
            if(r.length > 0){
                document.getElementById('loadingImg').style.visibility = "hidden";

            else {
            alert("Call Web service");
            document.getElementById('loadingImg').style.visibility = "visible"; 

             var pl = new SOAPClientParameters();
             var parameter1 = "";
             var parameter2 = "";
             pl.add("parameter1", parameter1);
             pl.add("parameter2", parameter2);

             SOAPClient.invoke(WSDLURL, "stationSearch", pl, true, GetStationCodes_callBack);

        function GetStationCodes_callBack(r)
            alert("Web service Response"+r);
         document.getElementById('loadingImg').style.visibility = "hidden";
             window.localStorage.setItem("stations", JSON.stringify(r));


<body onload="GetStationCodes()">
<div id="wrapper">
  <div class="dashboard_cont">
   <div class="topbar">
    <div class="home_icon"><a href="#"><img src="images/back-arw.png" alt="Home" title="Home" /></a></div>
    <h1 class="fr"><a href="#"><img src="images/icon1.png" alt="" /></a></h1>
    <a href="#"><img src="images/dwn_arw.png" alt="" width="18" height="12" /></a>
    <div class="cl"></div>


      <img src="images/ajax-loader.gif" id="loadingImg" visible =true style="margin:auto; position: absolute; left:50%; top:50%;"/>
      <li><a href="newarrivals.html" class="arivals" ></a> </li>
         <li><a href="newdeparture.html" class="departure" ></a> </li>
            <li><a href="" class="journey" ></a> </li>
               <li><a href="" class="destination" ></a> </li>
                  <li><a href="" class="count" ></a> </li>
                     <li><a href="" class="dispatch" ></a> </li>
                        <li><a href="" class="faultreport" ></a> </li>
                           <li><a href="" class="addapp" ></a> </li>
    <div class="cl"></div>


Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: why window.local storage not work on android

Sorry this is a blackberry forum.


Try looking at: http://caniuse.com/


Search for localstorage and you will see which browsers can handle what you need.

If it helped you, click like. Smiley Happy
BlackBerry Development Advisor
Posts: 769
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: why window.local storage not work on android



Please post your Android questions in a Google forum.  We cannot help you in here with them https://www.google.ca/#hl=en&sugexp=les%3B&gs_nf=3&tok=4f8Yaq7O6LcXyMonzuJAQw&cp=17&gs_id=2i&xhr=t&q...

Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: why window.local storage not work on android

Thanks i got the solution

Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: why window.local storage not work on android

Hi Ravi,


May I know the Solution ?

I am also facing same issue... local storage works on Android and Playbook ported app but not on BB10



Abhinav Tyagi

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot