0
这里是模式:SQLite查询:获取一行(android)的所有列?
SQL查询是: SELECT *从unjdat其中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永远不能为null,任何COL_2到col_11可能对某些行是空的。
- 表中的所有列和所有行都是唯一的。
非常感谢你! –
@ArjunU很乐意帮忙 – MDMalik