I am using Room Persistence Library. The operation works as expected. But how do I get onConflict
value from DAO back from calling method. I get the following error
error: Not sure how to handle the insert method's return type.
Update After I change return type from Integer to long, I get this error
Not sure how to handle update method's return type. Currently the supported return types are void, int or Int.
In DAO.java
@Dao
public interface UserDao {
@Insert(onConflict = OnConflictStrategy.ABORT)
long insert(UserEntity userEntity);
@Update(onConflict = OnConflictStrategy.IGNORE)
long update(UserEntity userEntity);
}
In MainActivity.java
@Override
protected Void doInBackground(UserEntity... userEntities) {
long result = userDao.insert(userEntities[0]);
if(result == OnConflictStrategy.ABORT){
result = userDao.update(userEntities[0]);
}
return null;
}