数据库
首页 > 数据库> > realm数据库报错:Changing Realm data can only be done from inside a transaction.

realm数据库报错:Changing Realm data can only be done from inside a transaction.

作者:互联网

在编写realm数据库相关时:

代码:

  List<Student> delByStudent(String priNum){
        RealmResults<Student> studentsList = myStudentRealm.where(Student.class).equalTo("num",priNum).findAll();
        for (int i = 0;i<studentsList.size();i++)
            studentsList.deleteFirstFromRealm();
        return studentsList;

在for的循环语句

studentsList.deleteFirstFromRealm();

报错:

标签:myStudentRealm,transaction,realm,数据库,报错,studentsList,data,priNum
来源: https://www.cnblogs.com/catherineliu/p/13049294.html