我在我的应用程序中使用Realm来保存数据库中的用户名和年龄值,但在我的一个类方法中,当我在下面的代码中写入时,它将显示错误消息:
错误消息: -
can not resolve method 'executeTransactionAsync(anonymous io.realm.Realm.Transaction,,)'
方法: -
private void save_into_database(final String name, final int age) {
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm bgRealm) {
User user = bgRealm.createObject(User.class);
user.setName(name);
user.setEmail(age);
}
}, new Realm.Transaction.OnSuccess() {
@Override
public void onSuccess() {
// Transaction was a success.
}
}, new Realm.Transaction.OnError() {
@Override
public void onError(Throwable error) {
// Transaction failed and was automatically canceled.
}
});
}
所以如何处理这个错误,提前谢谢。