Search in sources :

Example 6 with SupportSQLiteDatabase

use of android.arch.persistence.db.SupportSQLiteDatabase in project sqlbrite by square.

the class BriteDatabase method delete.

/**
 * Delete rows from the specified {@code table} and notify any subscribed queries. This method
 * will not trigger a notification if no rows were deleted.
 *
 * @see SupportSQLiteDatabase#delete(String, String, Object[])
 */
@WorkerThread
public int delete(@NonNull String table, @Nullable String whereClause, @Nullable String... whereArgs) {
    SupportSQLiteDatabase db = getWritableDatabase();
    if (logging) {
        log("DELETE\n  table: %s\n  whereClause: %s\n  whereArgs: %s", table, whereClause, Arrays.toString(whereArgs));
    }
    int rows = db.delete(table, whereClause, whereArgs);
    if (logging)
        log("DELETE affected %s %s", rows, rows != 1 ? "rows" : "row");
    if (rows > 0) {
        // Only send a table trigger if rows were affected.
        sendTableTrigger(Collections.singleton(table));
    }
    return rows;
}
Also used : SupportSQLiteDatabase(android.arch.persistence.db.SupportSQLiteDatabase) WorkerThread(android.support.annotation.WorkerThread)

Aggregations

SupportSQLiteDatabase (android.arch.persistence.db.SupportSQLiteDatabase)6 WorkerThread (android.support.annotation.WorkerThread)3 HashMap (java.util.HashMap)3 Method (java.lang.reflect.Method)2 Pair (android.util.Pair)1 Response (com.amitshekhar.model.Response)1 TableDataResponse (com.amitshekhar.model.TableDataResponse)1 UpdateRowResponse (com.amitshekhar.model.UpdateRowResponse)1