title: Android auto refresh when new data inserted into listview
body: <p>I've been developing android application.
  I have back end ( Web Application ) and front end ( Android Application ).</p>
  
  <p>In my application, it has category that contain a bunch of list of items.
  When i choose a category, it will call a task that use to call all data in DB.
  Once task complete call all data, it'll direct to activity.
  And activity will show all data in a ListView.</p>
  
  <p>Now, for example i insert a new data from back end ( Web ).
  Let just say i insert a new row contain a boxing into sport category.
  So, in DB it'll have boxing in table sport.</p>
  
  <p>And in my android application, i'm currently in sport category.
  So, when boxing inserted into new DB, it should have auto refresh and show me boxing in the list.</p>
  
  <p>But how do i do it when the task only run once when i click a category in category list ?
  i want to compare the total of data in DB and the data that shown in android application.
  When the data isn't the same, it'll call the task again.</p>
  
  <p>This is the code where i want my application to refresh</p>
  
  <pre><code>ConnectivityManager connManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
  
      if(mWifi.isConnected()) 
      {
          refresh = new Runnable() {
              public void run() {
                  // Do something
                  handler.postDelayed(refresh, 1000);
              }
          };
          handler.post(refresh);
  
          /*gridArray = new ArrayList&lt;FlipItem&gt;();
          adapter = new PackageListItemAdapter(this, this, gridArray);        
          adapter.notifyDataSetChanged();*/
  
      }
      else
      {
          refresh = new Runnable() {
              public void run() {
                  // Do something
                  handler.postDelayed(refresh, 60000);
              }
          };
          handler.post(refresh);
          /*gridArray = new ArrayList&lt;FlipItem&gt;();
          adapter = new PackageListItemAdapter(this, this, gridArray);        
          adapter.notifyDataSetChanged();*/
      }
  </code></pre>
  
  <p>The code where i comment there, make my list only show about 9 where i have 15 items on DB.
  That's why i comment that line</p>