I'm trying to get a value I have saved in Realm
, but I don't know how to do it.. the value is always null.. but when I'm debugging the code, the value appear as you can see in the image below:
Note:
BookMarkActive
&idBookMark
has the proper value in the selected line but below does not appear anything.
How can I get the value?
Take a look the same code as in the image:
public String UpdateBookMarks(String id){
Realm realm = Realm.getInstance(_context);
RealmQuery<Bookmark> query = realm.where(Bookmark.class);
query.equalTo("IdBookMark", id);
Bookmark stationDetails = query.findFirst();
if(stationDetails.getBookMarkActive() == "true"){
stationDetails.setIdBookMark("false");
return "Station has been removed from your bookmark list.";
}else if (stationDetails.getBookMarkActive() == "false"){
stationDetails.setIdBookMark("true");
return "Station has been added to your bookmark list.";
}
return "Error";
}
BookMark class:
@RealmClass
public class Bookmark extends RealmObject {
private java.lang.String IdBookMark;
private String BookMarkActive;
public String getIdBookMark() {
return IdBookMark;
}
public void setIdBookMark(String idBookMark) {
IdBookMark = idBookMark;
}
public String getBookMarkActive() {
return BookMarkActive;
}
public void setBookMarkActive(String bookMarkActive) {
BookMarkActive = bookMarkActive;
}
}
Note: Realm version 'io.realm:realm-android:0.87.2'