title: Refreshing TableLayout to show new rows inserted
body: <p><strong>Background:</strong></p>
  <p>I have created an Orders table in a database and I am manipulating it in two activities namely <code>CurrentOrders</code> and <code>NewOrders</code> respectively.</p>
  <p><code>CurrentOrders</code> activity shows the current orders stored inside the database in a <code>TableLayout</code>. And to add new orders to the table I have specified a button namely <code>addOrders</code> which when clicked loads <code>NewOrders</code> activity.</p>
  <p><em>CurrentOrders:</em></p>
  <pre><code>public class CurrentOrders extends AppCompatActivity {
      
      private TableLayout table;
      populateTable(Cursor records){
             
             TableRow row = new TableRow(this);
             TextView product = new TextView(this);
             TextView price = new TextView(this);        
  
             product.setText(records.getString(1));        
             price.setText(records.getString(2));          
             row.addView(product);
             row.addView(price);
  
             table.addView(row);
      } 
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_current_orders);
          
          Cursor cursor = db.query(&quot;orders&quot;, null, null,
                  null, null, null, null);  
  
          table = findViewById(R.id.tab);             
  
          while(cursor.moveToNext())                 
             populateTable(cursor);
      }
  
      public void addOrders(View view){
         startActivity(new Intent(getApplicationContext(), NewOrders.class));        
      } 
  }
  </code></pre>
  <p><code>NewOrders</code> activity acts like a form by having a <code>TableLayout</code> whose cells/fields are specified as <code>EditText</code> in order to let user type the orders they want to store. And to save the orders inside the database I have specified a submit button which when clicked store the value of <code>EditText</code> inside the Orders table in database and then goes back to parent activity (<code>CurrentOrders</code>) to show all the orders in the database.</p>
  <p><em>NewOrders:</em></p>
  <pre><code>public class NewOrders extends AppCompatActivity {
      
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_new_orders);                        
      }
  
      public void submit(View view){
          
          TableLayout table = findViewById(R.id.newOrders);
          int count = table.getChildCount();
          
          for (int idx = 0; idx &lt; count; idx++){
  
              TableRow row = (TableRow) table.getChildAt(idx);
  
              EditText product = (EditText) row.getChildAt(1);
              EditText price = (EditText) row.getChildAt(2);
  
              String productVal = product.getText().toString();
              double priceVal = Double.parseDouble(price.getText().toString());
  
              long result = db.insert(productVal, priceVal);           
          }
          Toast.makeText(this, &quot;Saved.&quot;, Toast.LENGTH_SHORT).show();
           onBackPressed();
      }
  }
  </code></pre>
  <p><strong>Problem:</strong></p>
  <p>I don't see new records inserted until an unless I reload the <code>CurrentOrders</code> activity. I want to show all the records (included new ones) without having to reload the activity.</p>