Skip to content

Commit

Permalink
3335-LossOfPrecision
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowandy committed Mar 12, 2011
1 parent 86cfe14 commit 952230b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions android/titanium/src/org/appcelerator/titanium/TiProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,24 @@ public double getDouble(String key, double def)
if (DBG) {
Log.d(LCAT,"getDouble called with key:"+key+", def:"+def);
}
return (double)preferences.getFloat(key,(float)def);
if( !this.hasProperty(key) )
return def;

String stringValue = preferences.getString(key,"");
try {
return Double.parseDouble(stringValue);
} catch (NumberFormatException e) {
return def;
}
}
public void setDouble(String key, double value)
{
if (DBG) {
Log.d(LCAT,"setDouble called with key:"+key+", value:"+value);
}

SharedPreferences.Editor editor = preferences.edit();
editor.putFloat(key,(float)value);
editor.putString(key,value + "");
editor.commit();
}
public boolean getBool(String key, boolean def)
Expand Down

0 comments on commit 952230b

Please sign in to comment.