code: public synchronized int purge() {
          int recordsRemaining = -1;
          SQLiteDatabase db = null;
          Cursor cursor = null;
          try {
              db = getWritableDatabase();
  
              // Purge records.
              long earliestValidTime = System.currentTimeMillis() - RECORD_EXPIRY_TIME;
              int recordsDeleted = db.delete(ShareRequestTable.NAME, WHERE_CLAUSE_PURGE_POLICY,
                      new String[]{String.valueOf(earliestValidTime), String.valueOf(ShareRequest.STATE_PROCESSED),
                              String.valueOf(RECORD_MAX_FAILS)}
              );
  
              // Check number of records remaining in the table.
              cursor = db.query(ShareRequestTable.NAME, new String[]{ShareRequestTable.COLUMN_ID}, null, null, null,
                      null, null);
              if (cursor != null) {
                  recordsRemaining = cursor.getCount();
              }
  
              sLogger.log(WingsDbHelper.class, "purge", "recordsDeleted=" + recordsDeleted + " recordsRemaining="
                      + recordsRemaining);
          } catch (SQLException e) {
              // Do nothing.
          } finally {
              if (cursor != null) {
                  cursor.close();
              }
              db.close();
          }
  
          return recordsRemaining;
      }
docs: Purges the database based on the purge policy.
  
  @return the number of records remaining after the purge; or -1 if an error occurred.