如何从sqlite的光标列值? [英] How to get column value from sqlite cursor?

查看:197
本文介绍了如何从sqlite的光标列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从光标列值,该列在查询所内计算运行时产生的,我正在此列空值,我能够得到所有其他列存在于SQLite表的价值

I am trying to get column value from cursor, this column is generated at run time by calculations inside the query, i am getting null value of this column , i am able to get value of all other columns which exists in sqlite table.

我执行的sqlite的编辑器相同的查询,这也说明生成的列在结果集中的值。

i execute the same query on sqlite editor , it also shows the value of generated column in result set.

为什么这让当我从游标检索该空值?

why this giving null value when i am retrieving it from cursor?

推荐答案

很简单,你可以通过以下方式得到它

Very Simple you can get it by either of following way

String id = cursor.getString( cursor.getColumnIndex("id") ); // id is column name in db

String id = cursor.getString( cursor.getColumnIndex(0)); // id is first column in db

这篇关于如何从sqlite的光标列值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆