Thái Ngô Thái Ngô - 1 month ago 17
Android Question

Realm findAll() some time empty?

AsyncTask.execute(new Runnable() {
@Override public void run() {
if (isbackendLoad){
// Backend load I must use syn retrofit because some reason.
// saveResulttoRealm
} else {
final Realm realm = Realm.getDefaultInstance();
RealmResults<RealmAnimal> realmAnimals =
realm.where(RealmAnimal.class).equalTo("DogId",DogId, Case.INSENSITIVE).findAll();

In Animal I have DogId field. I check in realm browser, it have Animal with DogId but result is empty. This realm query without AsyncTask.execute work ok. The reason is AsyncTask.execute ?. But I must use the for Syn Retorfit, without it retrofit return null.
Some thread Ex: Async #1 return null, Aysnc other have result != null.


you should get result in right time . exactly after the AsyncTask done . before this process will return null . check the return value in finally { it will show you that your problem where happen .