Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check realm for android data existence?

Tags:

android

realm

how do I check whether certain value is exist or not in my realm database based on this code below?

realm.where(User.class).equalTo("cardId", cardId).findFirst()

Thanks in advance.

like image 486
Azlan Jamal Avatar asked Jun 27 '16 06:06

Azlan Jamal


1 Answers

You can perform null check.

User user = realm.where(User.class).equalTo("cardId", cardId).findFirst();

if (user != null) {
    // Exists
} else {
    // Not exist
}
like image 66
Niko Avatar answered Sep 17 '22 18:09

Niko