There is no from
or to
method to select data from DB in Realm, when i try to use between()
, I get an unnecessary item at the end of result so I want to delete it after getting its copy to new listObject
.
But even after making copy of it in another list object i am not being able to delete the last item in the realmResult
.
RealmResults<CalendarDto> currentMonthDTOList = Realm.getDefaultInstance().where(CalendarDto.class).between("primaryDayId", startingDayPrimaryKey, endingDayPrimaryKey).findAll().sort("primaryDayId", Sort.ASCENDING);
List<CalendarDto> currentList = currentMonthDTOList;
currentList.remove(currentList.size());
But i get the error saying unsupportedOperationException.
My log cat looks like this
FATAL EXCEPTION: main
Process: com.toyanathpatro.gurkha, PID: 17714
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.toyanathpatro.gurkha/com.toyanathpatro.gurkha.activities.DashBoardActivity}: java.lang.ClassCastException: io.realm.RealmResults cannot be cast to java.util.ArrayList
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassCastException: io.realm.RealmResults cannot be cast to java.util.ArrayList
at com.toyanathpatro.gurkha.fragments.GridCalendarFragment.fetchData(GridCalendarFragment.java:84)
at com.toyanathpatro.gurkha.fragments.GridCalendarFragment.onCreateView(GridCalendarFragment.java:42)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:601)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
at android.app.Activity.performStart(Activity.java:6253)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Aucun commentaire:
Enregistrer un commentaire