Android sqlite 数据类型
来源:互联网 发布:郑州淘宝客服招聘包住 编辑:程序博客网 时间:2024/06/01 10:38
场景:一直做金融行业项目,所以数据的精确性十分重要
执行代码查询数据(数据精确到小数点2位)和直接执行SqL所查询数据不一致,经排查发现
value = cursor.getString(cursor.getColumnIndex(ss[i]));在作怪,此方法对Double数据进行了怎样处理,还需深究
解决方法如下:
if(cursor.getType(cursor.getColumnIndex(ss[i])) == Cursor.FIELD_TYPE_FLOAT){value = cursor.getDouble(cursor.getColumnIndex(ss[i]))+"";} else { value = cursor.getString(cursor.getColumnIndex(ss[i]));}
SQLite具有以下五种数据类型:
1.NULL:空值。
2.INTEGER:带符号的整型,具体取决有存入数字的范围大小。
3.REAL:浮点数字,存储为8-byte IEEE浮点数。
4.TEXT:字符串文本。
5.BLOB:二进制对象。
/** Value returned by {@link #getType(int)} if the specified column is null */
static final int FIELD_TYPE_NULL = 0;
/** Value returned by {@link #getType(int)} if the specified column type is integer */
static final int FIELD_TYPE_INTEGER = 1;
/** Value returned by {@link #getType(int)} if the specified column type is float */
static final int FIELD_TYPE_FLOAT = 2;
/** Value returned by {@link #getType(int)} if the specified column type is string */
static final int FIELD_TYPE_STRING = 3;
/** Value returned by {@link #getType(int)} if the specified column type is blob */
static final int FIELD_TYPE_BLOB = 4;
- Android SQLITE数据类型
- android的SQLite数据类型
- android sqlite 数据类型
- Android sqlite 数据类型
- android sqlite 数据类型
- android sqlite数据库数据类型
- android sqlite支持的数据类型
- Android 和 SQLite 基本数据类型
- android数据库sqlite松散数据类型
- android sqlite支持的数据类型
- android sqlite支持的数据类型
- android sqlite支持的数据类型
- android sqlite支持的数据类型
- android sqlite支持的数据类型
- Android IOS SQLite 数据库 数据类型
- Android SQLite数据库—数据类型
- android sqlite支持的数据类型
- android数据库---sqlite,所支持的数据类型
- 错误: 编码GBK的不可映射字符
- 设置python 命令行交互程序自动补齐
- iOS-ui-normal_ui_control
- 设计模式那点事--建造者模式
- git常用命令
- Android sqlite 数据类型
- GRE写作必备句型
- CSS简单理解与应用
- Android平台下利用zxing实现二维码开发(取景器横线扫描)
- 阿里云服务器去掉tomcat的8080端口和项目名
- windows端口占用及结束进程
- Windows平台分布式架构实践 - 负载均衡(下)
- 从WordCount看Spark大数据处理的核心机制(2)
- maven添加镜像地址