Hello this is my first Question in StackOverflow. I have table with two coloumns (productname and answer) when i give a number, cursor need to go to that row and get that data. well simply if i give 5 to QuestionID, c1 cursor needs to go to 5th cell in coloumn productname and c2 cursor needs to go to 5th cell in coloumn answer.
please look at the code.... sorry for the bad English.English is not my Native Language.
public void getexactrow(String QuestionID){
this._QuestionID=QuestionID;
SQLiteDatabase db = getWritableDatabase();
String colomn1 = "SELECT " +COLUMN_PRODUCTNAME+ " FROM " + TABLE_PRODUCTS + " WHERE 1";
String colomn2 = "SELECT " +COLUMN_ANSWER+ " FROM " + TABLE_PRODUCTS + " WHERE 1";
Cursor c1 = db.rawQuery(colomn1, null);
Cursor c2 = db.rawQuery(colomn2, null);
c1.move(Integer.parseInt(_QuestionID));
c2.move(Integer.parseInt(_QuestionID));
if (c1.getString(c1.getColumnIndex("productname")) != null) {
_SendQuestion = c1.getString(c1.getColumnIndex("productname"));
}
if (c2.getString(c2.getColumnIndex("answer")) != null) {
_SendAnswer = c2.getString(c2.getColumnIndex("answer"));
}
}
Aucun commentaire:
Enregistrer un commentaire