Thái Ngô Thái Ngô - 1 year ago 159
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.

Answer Source

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 .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download