I\'m using realm to store my data on Android. Awesome framework! Now the only problem I\'m now having is:
I got a array list strings with id\'s of Countries in my da
Since the Realm database has added RealmQuery.in() with the version 1.2.0
I suggest using something like this.
//Drinks
public class Drinks extends RealmObject {
@PrimaryKey
private String id;
private String name;
private String countryId;
//getter and setter methods
}
//Country
public class Country extends RealmObject {
@PrimaryKey
private String id;
private String name;
//getter and setter methods
}
The code to use inside activity/fragments to retrieve drink list
String[] countryIdArray = new String[] {"1","2","3"} //your string array
RealmQuery realmQuery = realm.where(Drinks.class)
.in("countryId",countryIdArray);
RealmResults drinkList = realmQuery.findAll();