我想在sqlite表字段中存储I字符串,它看起来像一个整数。 sqlite中字段的定义:
“时间字符串”
例如对于值“126.70”,我希望它存储为完整的字符串,但我在数据库“126.7”中看到,所以最后的零被剪切(如整数)
这是我的代码:
String time = "126.70";
ContentValues cv = new ContentValues();
cv.put("time", time);
db.replace(TABLE, null, cv);
如何避免这种行为?
答案 0 :(得分:0)
string
不是sqlite列类型,因此默认值适用。请改用text
:
sqlite> create table a(b text, c real);
sqlite> insert into a values("123.10", "123.10");
sqlite> select * from a;
123.10|123.1