如何从sqlite的光标列值?光标、sqlite

2023-09-06 02:53:37 作者:爱我的人会发光i

我想从光标列值,该列在查询所内计算运行时产生的,我正在此列空值,我能够得到所有其他列存在于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