gpt4 book ai didi

Android - SQLite Cursor getColumnIndex() 是否区分大小写?

转载 作者:IT王子 更新时间:2023-10-29 06:21:50 27 4
gpt4 key购买 nike

在 Android 中使用 SQLiteCursor 时,我了解到 getColumnIndex() 是区分大小写的,例如:

示例:

数据库中的列名是:Rules

cursor.getColumnIndex("Rules")  //works fine
cursor.getColumnIndex("rules") //throws error, see the error detail

文档对此没有任何说明,详情 please see this .

LogCat 说:

java.lang.IllegalStateException: Couldn't read row 0, col -1 fromCursorWindow. Make sure the Cursor is initialized correctly beforeaccessing data from it

我对 SQLiteCursor 的这种行为感到困惑,有人可以帮助我确定这是真的还是我做错了什么?如果需要,我可以提供代码。

谢谢。

最佳答案

getColumnIndex() 区分大小写:

数据库中的列名称为:Rules

cursor.getColumnIndex("Rules") //工作正常

cursor.getColumnIndex("rules")//抛出错误,查看错误详情

关于Android - SQLite Cursor getColumnIndex() 是否区分大小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9029668/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com