Check if map key greater than value

Habib :

I want to make buildAlertMessageVersion() execute only when the value of child "version" is higher than 1.5

Here is the example I used but it only works if it's equals to 1.5

@Override
public void onDataChange(DataSnapshot dataSnapshot) {
    if(dataSnapshot.exists()) {
        Map<String, Object> map = (Map<String, Object>) dataSnapshot.getValue();
        if(map.get("version").equals(1.5)){
            buildAlertMessageVersion();
        }
    }
}
Rias :

Change

if(map.get("version").equals(1.5)) to if(map.get("version") > 1.5)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=195135&siteId=1