title: SQLite Update Method for Android
body: <p>My question is how to you call a method like this.  I already know how to implement it.  Here is the method content:</p>
  
  <pre><code> public boolean updateDebt(long updateId, String debtName, String debtTotal,
          String debtApr, String paymentGoal) {
  
       ContentValues values = new ContentValues();
       values.put(MySQLiteHelper.COLUMN_DEBT_NAME, debtName);
       values.put(MySQLiteHelper.COLUMN_DEBT_TOTAL, debtTotal);
       values.put(MySQLiteHelper.COLUMN_APR, debtApr);
       values.put(MySQLiteHelper.COLUMN_PAYMENT, paymentGoal);
       String whereClause = MySQLiteHelper.COLUMN_ID + " = ?";
       String[] whereArgs = new String[]{ String.valueOf(updateId) };
       return database.update(MySQLiteHelper.TABLE_DEBT, values, whereClause, whereArgs) &gt; 0;
  </code></pre>
  
  <p>My questions lies in <strong>calling</strong> this updateDebt Method.</p>
  
  <p>Picture a dialog with four fields with an update button.  The fields are pre-populated with table data.  The user changes field data and hits update, the table should change.</p>
  
  <p>This is the code that comes before the call.  Keep in mind, I am calling it via an onClick inside a dialog inside an onListItemClick.  </p>
  
  <p>(I've edit lots of unrelated stuff out)</p>
  
  <pre><code>List&lt;Debt&gt; values;
  MyArrayAdapter adapter;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.debts);
  
      datasource = new DebtDataSource(this);
      datasource.open();
      values = datasource.getAllDebt();
      adapter = new MyArrayAdapter(this, values);
      setListAdapter(adapter);
  
    }
  
   protected void onListItemClick(ListView l, View v, final int position, long id) {
  
      Debt item = values.get(position);
  
      final long boxId = item.getId();
      final String BoxName = item.getName();
      final String BoxBalance = item.getBalance();
      final String BoxApr = item.getApr();
      final String BoxPayment = item.getPayment();
  
   // (edited out: setting up EditText fields here with data from above)
  
      // set up button
      Button button = (Button) dialog.findViewById(R.id.button1);
      button.setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
  
  
              datasource.updateDebt(Long.valueOf(boxId), BoxName, BoxBalance,
                      BoxApr, BoxPayment);
              values = datasource.getAllDebt();
              adapter.notifyDataSetChanged();
              dialog.dismiss();
  
          }
      });
  
      dialog.show();
  }
  </code></pre>
  
  <p>Simply put nothing happens when I hit update.  The dialog dismisses, that' it. Nothing in logcat.  I have logged out the variables just before the update method inside the updateDebt() method.  I have toasted them back and all the variables match up perfectly.  The database doesn't change though! 
  Struggling on this for days....</p>