title: How to check device is Online or Offline Phonegap
body: <p>What is the easiest way to check whether the device(smartphone) is online or offline. 
  I'm working with phonegap, jquery mobile. 
  I found this one. </p>
  
  <pre><code>document.addEventListener("online", yourCallbackFunction, false);
  </code></pre>
  
  <p>What I want to do is to check the Internet connection and decide about to get the data from the internet or from the device local database. </p>
  
  <pre><code>if(deviceoffline)
    getDataFromLokalDatabase();
  else
    getDataFromInternet();
  </code></pre>