【发布时间】:2014-04-05 18:42:29
【问题描述】:
这是架构:
SQL 查询是: SELECT * from unjdat where col_1 = "myWord";
即,我想显示 col_1 为 myWord 的行的所有列。
int i;
String temp;
words = new ArrayList<String>();
Cursor wordsCursor = database.rawQuery("select * from unjdat where col_1 = \"apple\" ", null); //myWord is "apple" here
if (wordsCursor != null)
wordsCursor.moveToFirst();
if (!wordsCursor.isAfterLast()) {
do {
for (i = 0; i < 11; i++) {
temp = wordsCursor.getString(i);
words.add(temp);
}
} while (wordsCursor.moveToNext());
}
words.close();
我认为问题在于循环。如果我删除 for 循环并执行 wordsCursor.getString(0) 它可以工作。 如何循环获取所有列?
注意:
- col_1 永远不会为空,对于某些行,col_2 到 col_11 中的任何一个都可能为空。
- 表中的所有列和所有行都是唯一的。
【问题讨论】:
标签: java android sqlite android-sqlite