Android Realm Java 0.82.1 ArrayIndexOutOfBoundsException

mrpep

尝试从领域(0.82.1)更新对象时出现此错误:

rowIndex>可用行:0> 0

Realm realm = null;

try{
    realm = Realm. getInstance ( context );
    RealmResults<Track> results = realm.allObjects( Track.class )
        .where()
        .equalTo("fileType", type)
        .equalTo("fileState", actualState)
        .equalTo("fileName", fileName)
        .findAll();

   //At this point result.size() = 1

   for( int i = 0; i < results.size(); i++ )
   {
       realm.beginTransaction();
       results.get( i ).setFileState(newState);
       realm.commitTransaction();
   }

}catch ( RealmException e ) {
    Log.d( TAG, e.getMessage());
}catch ( RealmIOException e ) {
    Log.d( TAG, e.getMessage());
}catch ( Exception e ) {
    Log.d( TAG, e.getMessage());
}
finally {
    if (realm != null) {
        realm.close();
    }
}

我也尝试过使用Iterator,但是有相同的错误。

概括:

  • 每次都崩溃。(我已经看过多次了)
  • 它是可重现的。
  • 在Android 4.4.4(Samsung Galaxy S3),5.0.1(Samsung Galaxy Note4)上遇到的崩溃

崩溃在for循环中。我捕获到的异常是:

rowIndex 0 > 0 - invalid!
jni: ThrowingException 7, rowIndex > available rows: 0 > 0

有什么办法吗?

伊曼纽雷斯

发生这种情况是因为您正在修改要遍历的RealmResults。这是一个已知问题,您可以在此处关注其进度:https : //github.com/realm/realm-java/issues/640

解决方法是,可以在迭代过程中将要修改的对象保存在另一个列表中,然后迭代新列表以进行实际修改。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

向量java java.lang.ArrayIndexOutOfBoundsException:length = 0; 索引= 1

Android Java ArrayIndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException:0

解析错误... ArrayIndexOutOfBoundsException 1 JAVA

Java Android Realm包含

java.lang.ArrayIndexOutOfBoundsException: 1 >= 1

ArrayIndexOutOfBoundsException = 0

Android Studio Kotlin二维Button数组得到java.lang.ArrayIndexOutOfBoundsException:length = 0; 索引= 0

Java Applet AWT-EventQueue-1 ArrayIndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException:0> = 0,尝试填充JTable

Realm java (android) 复合谓词

Android ArrayIndexOutOfBoundsException ..?

数组错误 java.lang.ArrayIndexOutOfBoundsException: length=1; 指数=1

如何修复java.lang.ArrayIndexOutOfBoundsException:length = 1; 索引= 1

java.lang.ArrayIndexOutOfBoundsException:0-数组是否大于索引?

线程“主”中的异常java.lang.ArrayIndexOutOfBoundsException:0

验证签名 XADES 抛出 java.lang.ArrayIndexOutOfBoundsException: 0

args [0] == null线程“主”中的异常java.lang.ArrayIndexOutOfBoundsException:Main.main处为1(Main.java:69)

运行时出现“ java.lang.ArrayIndexOutOfBoundsException:1”错误

java.lang.ArrayIndexOutOfBoundsException: -1 future.get() 多线程

如何处理:java.lang.ArrayIndexOutOfBoundsException:1

xstream分析器错误:java.lang.ArrayIndexOutOfBoundsException:-1

我的程序给了我java.lang.ArrayIndexOutOfBoundsException:1

JTabbedPane ArrayIndexOutOfBoundsException: 0

线程“main”中的异常java.lang.ArrayIndexOutOfBoundsException:索引1超出长度0的界限,不知道这是什么意思或如何修复它

Realm Java Android:创建或更新对象

未知的原因:java.lang.ArrayIndexOutOfBoundsException:索引0超出命令行的长度0

Android Realm:主键约束已损坏。值已存在:0

ArrayIndexOutOfBoundsException:2> = 1 on每个