Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Android™ Runtime Development

Reply
Developer
ravi1989
Posts: 740
Registered: ‎07-21-2012
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">
<head>
<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() 
        {

            checkConnection();
           // 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 ");
                navigator.app.exitApp();
            }   
        }


           var stationList = new Array; 


        function GetStationCodes()
        {    
            var r = JSON.parse(window.localStorage.getItem("stations"))||[];
            alert("Time"+r);
            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));



        }

    </script>
</head>
<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>
    Dashboard
    <a href="#"><img src="images/dwn_arw.png" alt="" width="18" height="12" /></a>
    <div class="cl"></div>

    </div>
     <div>

      <img src="images/ajax-loader.gif" id="loadingImg" visible =true style="margin:auto; position: absolute; left:50%; top:50%;"/>
    <ul>
      <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>
    </ul>
    </div>
    <div class="cl"></div>
  </div>
</div>
</body>
</html>

 

Please use plain text.
Developer
The_Anomaly
Posts: 316
Registered: ‎08-06-2012

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. :smileyhappy:
Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 375
Registered: ‎10-01-2009
My Carrier: Bell

Re: why window.local storage not work on android

Ravi, 

 

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...

Please use plain text.
Developer
ravi1989
Posts: 740
Registered: ‎07-21-2012
My Carrier: 0

Re: why window.local storage not work on android

Thanks i got the solution

Please use plain text.
Developer
abhi007tyagi
Posts: 215
Registered: ‎09-29-2010
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

 

Thanks

Abhinav Tyagi

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