title: Updating Android SQLite database table while user operates App and avoid errors/poor user experience
body: <p>My Android App has a products table in an SQLite database that comes pre-populated when the user installs it.  The table can be updated from an Azure web service.  </p>
  
  <p>Instead of returning only the updated records from the web service and populating the SQLite table with the updated records, I want to simply return the 2900 records to the App.  This is because most of the products will have changed.  On opening the App, the products table is deleted using an SQL query and the ksoap2 response is sent to Product objects which are inserted into the database.</p>
  
  <p>While this update to the products table is happening, I would like the user to be able to use the App without disruption.  If the Products table has been deleted, then they cannot operate the App properly.  </p>
  
  <p>What are my options?  Could I populate a temporary Product table and when the service has finished populating it, I could copy it to the 'live' Product table.  Or could I completely delete the Product table and rename the temporary table to "Product"?</p>
  
  <p>Or am I going about this completely wrong.  Any advice would be most appreciated.
  Code extract below:</p>
  
  <pre><code> try {
  
            productDatasource.open();
            productDatasource.deleteProductTable();
            productDatasource.close();
            ArrayList&lt;Product&gt; arrProduct = new ArrayList&lt;Product&gt;();
            SoapObject request = new SoapObject(NAMESPACE, PRODUCT_METHOD_NAME); 
  
           SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
           envelope.dotNet = true;
           envelope.setOutputSoapObject(request);
           System.out.println("startit");
           HttpTransportSE ht = new HttpTransportSE(URL);
           ht.debug = true;
           ht.call(SOAP_ACTION_PRODUCT, envelope);
  
           SoapObject response = (SoapObject) envelope.getResponse();
  
           productDatasource.open();
           productDatasource.deleteProductTable();
           Product[] products = new Product[response.getPropertyCount()];
  
           for (int i = 0; i &lt; products.length; i++) {
  
               SoapObject prodObj = (SoapObject)response.getProperty(i);
               Product product = new Product();
  
               product.setProductID(Integer.parseInt(prodObj.getProperty(10).toString()));
               product.setProductName(prodObj.getProperty(11).toString());
               product.setFKCategoryID(Integer.parseInt(prodObj.getProperty(5).toString()));
               product.setFKSubCategoryID(Integer.parseInt(prodObj.getProperty(13).toString()));
               product.setFKBrandID(Integer.parseInt(prodObj.getProperty(2).toString()));      
  
               productDatasource.createProduct(product);
           }
  </code></pre>