i have a database class with this method:
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;
}
in my activity, all i want is to use the results to populate view elements. i have this:
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")));
i get an error: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1
best regards
Aucun commentaire:
Enregistrer un commentaire