スキーマは次のとおりです。
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
ループを削除して a を実行するwordsCursor.getString(0)
と、機能します。すべての列を取得するためにループする方法は?
注:
- col_1 が null になることはありません。col_2 から col_11 のいずれかが、一部の行で null になる場合があります。
- テーブル内のすべての列とすべての行は一意です。