title: Progress bar to show only during long operations
body: <p>I am designing an application that fetches data from a sqlite database on the click of a button . I want to display a wait message or progress bar during the time of the fetch only if the process is long like say more than 3 secs . Otherwise it can just proceed with the program . How do i do this . i tried showing a progress dialog using the following code but it only waits for the specified sleep time and proceeds without showing anything .... plss help </p>
  
  <pre><code>protected void GetOrders() 
  {
      ProgressDialog dialog = null;
      try
      {
          dialog=ProgressDialog.show(loginScreen.this,"PLEASE WAIT","LOADING CONTENTS ..",true);
          //Accesses database 
          allOrders=ProductionOrdersBL.GetOrder();
          Thread.sleep(4000);
  
      }
      catch(Exception e){}
      finally
      {
          dialog.dismiss(); 
      }
  }
  </code></pre>