I am trying to compare two double values:
for(int i=0;i<count;i++){
Double i1=Double.parseDouble(pref.getString("longitude"+i, null));
Double i2=Double.parseDouble(pref.getString("latitude"+i,null));
Log.i("Longitude", i1+"");
Log.i("Latitude",i2+"");
Log.i("Longitude1",longitude+"");
Log.i("Latitude1", latitude+"");
Log.i("note",pref.getString("note"+i, null));
if(longitude==i1&&latitude==i2) {
String note=pref.getString("note"+i, null);
txt.setText(note);
}
}
There is one combination in shared preference that matches with longitude and latitude but in if when i compare its not assigning any value to textview txt.but in log there is a same value for latitude and latitude.can any one please tell whats wrong in this comparison why its not executing txt.settext statement?
Assuming
latitudeandlongitudeto beDoubletoo, try invoking thedoubleValueof both:or just use
equalswhich derives in the first line, under the hood.