When I store float value widt SQLiteDatabase.insert the stored value will be different than the original, see below:
I have a database width:
db.execSQL("CREATE TABLE IF NOT EXISTS info_values ("
+ BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "date DATE UNIQUE NOT NULL, "
+ "value REAL NOT NULL)");
When I insert eg 33.3 width:
private class inputdlg_ok implements input_dlg.ReadyListener {
public void ready(float newvalue) {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ContentValues values = new ContentValues();
values.put("date", sdf.format(d));
values.put("value", newvalue);
database.insert("info_values", null, values);
I have got these:
sqlite> select * from info_values;
83|2012-04-04 09:06:22|33.2999992370605
84|2012-04-02 09:05:57|22.2000007629395
I have tested width exec:
String sql = "INSERT INTO info_values (date, value) " +
"VALUES ('" + sdf.format(d) + "'," + Float.toString(newvalue) + ")";
database.execSQL(sql);
and that form works good.
any idea?