Hello, everyone I am a student who is currently practicing making an Android application using Realm.
I have a question while studying, so I'm posting a question like this.
Realm.where (.class) when finding through a query in realm.You can get the first stored data through findFirst(); (It's ambiguous to say it's the first time, and it's 'the oldest data I have')
On the other hand, there's no FindLast "T" The reason why I am looking for findLast is because
This is to specify the id which is the primary key of the data to be newly stored. In order to specify an id for the data to be newly stored, you must have the id of the last person in the existing one to get it
RealmResult<E> result = realm.where(E.class).findAll();
int id = result.get(result.size() - 1).getId();
Is this the only way to get it? Well, I think there's another way.
If there is a thing called findLast,
ind id = realm.where(E.class)findLast().getId();
Wouldn't it be possible to do it in one line? I did, but it's a shame that there's no findLast
Is there any other way?
realm
realm.where(E.class).findAll().sort("primary key", Sort.DESCENDING).findFirst()
That's possible
© 2024 OneMinuteCode. All rights reserved.