关键代码如下:
int count = 0;
SQLiteDatabase db = null;
Cursor cursor = null;
//执行创建数据库或是表的语句
db = openHelper.getReadableDatabase();
//执行通过用户名和密码的参数查询出用户,并保存在cursor中
cursor = db
.rawQuery(
"select count(*) as count from student where name=? and pwd=?",
new String[] { name, pwd });
//得到的用户信息通过moveToNext()方法,while语句循环输出
while (cursor.moveToNext()) {
count = cursor.getInt(cursor.getColumnIndex("count"));
}
问题:while语句中(即倒数第二段中的),cursor.getColumnIndex("count")语句,查询出来的是什么东西啊?getColumnIndex(string name),不是根据 name的名称获得它的列索引。可是rawQuery查询语句中,“select count(*) as count from student...”。