0
我有一个数据库类用这种方法:访问SQLite数据库结果来填充视图
public Cursor getQuoteById(int qid)
{
SQLiteDatabase db = this.getReadableDatabase();
String selectQuery = "SELECT * FROM quotes a LEFT JOIN authors b ON b.author_id=a.quote_author WHERE a.quote_id = ?";
Cursor results = db.rawQuery(selectQuery, new String[]{String.valueOf(qid)});
return results;
}
在我的活动,我要的是用成绩来填充视图元素。我有这样的:
Qdb = new DbHelper(this);
Cursor results = Qdb.getQuoteById(Integer.parseInt(id));
authorname = (TextView) findViewById(R.id.share_author_name);
authorname.setText(results.getString(results.getColumnIndex("first_name")));
我得到一个错误:
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
任何人都可以请指出我在做什么错?