Register now for Android Dev Summit 2019!

OnConflictStrategy

public abstract @interface OnConflictStrategy
implements Annotation

androidx.room.OnConflictStrategy


Set of conflict handling strategies for various Dao methods.

Summary

Constants

int ABORT

OnConflict strategy constant to abort the transaction.

int FAIL

This constant is deprecated. Does not work as expected. The transaction is rolled back. Use ABORT.

int IGNORE

OnConflict strategy constant to ignore the conflict.

int REPLACE

OnConflict strategy constant to replace the old data and continue the transaction.

int ROLLBACK

This constant is deprecated. Does not work with Android's current SQLite bindings. Use ABORT to roll back the transaction.

Inherited methods

Constants

ABORT

public static final int ABORT

OnConflict strategy constant to abort the transaction. The transaction is rolled back.

Constant Value: 3 (0x00000003)

FAIL

public static final int FAIL

This constant is deprecated.
Does not work as expected. The transaction is rolled back. Use ABORT.

OnConflict strategy constant to fail the transaction.

Constant Value: 4 (0x00000004)

IGNORE

public static final int IGNORE

OnConflict strategy constant to ignore the conflict.

An Insert DAO method that returns the inserted rows ids will return -1 for rows that are not inserted since this strategy will ignore the row if there is a conflict.

Constant Value: 5 (0x00000005)

REPLACE

public static final int REPLACE

OnConflict strategy constant to replace the old data and continue the transaction.

An Insert DAO method that returns the inserted rows ids will never return -1 since this strategy will always insert a row even if there is a conflict.

Constant Value: 1 (0x00000001)

ROLLBACK

public static final int ROLLBACK

This constant is deprecated.
Does not work with Android's current SQLite bindings. Use ABORT to roll back the transaction.

OnConflict strategy constant to rollback the transaction.

Constant Value: 2 (0x00000002)