0

UserDatabse我从领域中删除了一个条目Activity "A",当我在删除后测试它的大小UserDatabase时返回“1”,然后我开始Activity B,然后当以下行执行时:

 Realm realm = Realm.getDefaultInstance();
        final RealmResults<UserDatabase> stdList = realm.where(UserDatabase.class).findAll();
    Log.i("datatesthello","student databse size"+stdList.size());

我收到此错误:java.lang.IllegalStateException:

09-08 16:18:21.491 8517-9711/com.gurkhatech.hamroschool.guardian E/AndroidRuntime: FATAL EXCEPTION: Thread-1712
 Process: com.gurkhatech.hamroschool.guardian, PID: 8517
java.lang.IllegalStateException: Requested table is not in this Realm. Creating it requires a transaction: class_UserDatabase                                                                                       
at io.realm.internal.Group.getTable(Group.java:193)
at io.realm.RealmSchema.getTable(RealmSchema.java:230)
at io.realm.RealmSchema.getSchemaForClass(RealmSchema.java:250)
at io.realm.RealmQuery.<init>(RealmQuery.java:139)
at io.realm.RealmQuery.createQuery(RealmQuery.java:88)
at io.realm.Realm.where(Realm.java:1050)
at com.gurkhatech.hamroschool.guardian.SplashActivity.validLogin(SplashActivity.java:81)
at com.gurkhatech.hamroschool.guardian.SplashActivity.access$000(SplashActivity.java:20)
at com.gurkhatech.hamroschool.guardian.SplashActivity$1.run(SplashActivity.java:37)

另外,当我在 Log 中打印时,活动 B 中的 UserDatabase 的大小为“0”。

4

0 回答 0