title: Android: Count and delete rows from sqlite
body: <p>I want to delete some records from my database tables, for example <strong>table A</strong> and <strong>table B</strong>. Both <strong>table A</strong> and <strong>table B</strong> has a column name <code>sycn_status</code>. I want to delete only those records where the value of <code>sync_status</code> is <strong>C</strong>. For this purpose I wrote the following method but I'm getting the exception.</p>
  
  <pre><code>public void RemoveSyncData(){
  
      DBHelper = new DatabaseHelper(context); 
      //db = DBHelper.getWritableDatabase();
  
      db.execSQL("DELETE FROM "+ DATABASE_TABLE_DAILY_ATTENDANCE +" WHERE KEY_ATTENDANCE_SYN_STATUS ='C'");
      db.close(); 
  </code></pre>
  
  <p>Here I'm only checking for one table. and the second thing I want to count the deleting records so that users should know how much data is deleted. </p>
  
  <p>Logcat errors</p>
  
  <pre><code>06-29 05:02:55.845: E/AndroidRuntime(1594): FATAL EXCEPTION: main
  06-29 05:02:55.845: E/AndroidRuntime(1594): android.database.sqlite.SQLiteException: no such column:   KEY_ATTENDANCE_SYN_STATUS (code 1): , while compiling: DELETE FROM dailyattendance WHERE KEY_ATTENDANCE_SYN_STATUS ='C'
  06-29 05:02:55.845: E/AndroidRuntime(1594):     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
  06-29 05:02:55.845: E/AndroidRuntime(1594):     at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
  06-29 05:02:55.845: E/AndroidRuntime(1594):     at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
  </code></pre>
  
  <p>Database method for deleting records.
  i'm calling the delete method from the button click </p>
  
  <pre><code>    @SuppressLint("NewApi") public void CleanAppDataClick(View V) {
  
      progressDialog = new ProgressDialog(Others.this);
      progressDialog.setTitle("Cleaning");
      progressDialog.setMessage("Please wait...");//
      Log.e("button delete data", "clicked");           
      usersqlite_obj.open();
      usersqlite_obj.RemoveSyncData();     
      dismissLoadingDialog();
  }
  </code></pre>
  
  <p>Here is the method in database class.</p>
  
  <pre><code>public boolean RemoveSyncData(){
  
      DBHelper = new DatabaseHelper(context); 
      db.execSQL("DELETE FROM "+ DATABASE_TABLE_DAILY_ATTENDANCE +" WHERE "+KEY_ATTENDANCE_SYN_STATUS +"='C'");
      db.execSQL("DELETE FROM "+ DATABASE_TABLE_DCR +" WHERE "+KEY_DCR_SYN_STATUS +"='C'");
      db.execSQL("DELETE FROM "+ DATABASE_TABLE_DCRNV +" WHERE "+KEY_DCRNV_SYN_STATUS +"='C'");
  
  
      db.close();
      return true;
  
  }
  </code></pre>