Reputation: 8818
I have created Cursor
from any database table. It consists value of _id and corresponding name. For further operation, I need the value of "name" for any specific "_id". How it is possible using the Cursor.
Upvotes: 1
Views: 6557
Reputation: 1486
Very Simple you can get it by either of following way
String id = cursor.getString( cursor.getColumnIndex("id") ); // id is column name in db
or
String id = cursor.getString( cursor.getColumnIndex(0)); // id is first column in db
Upvotes: 0
Reputation: 508
String selecttSqlStr2 = "SELECT * FROM Tablename WHERE TRIM(QST_Id) = '" + _id;
Cursor c = datasource.execSelectSQL(selecttSqlStr);//datasource is object for opening database
c.moveToFirst();
String name=c.getString(c.getColumnIndex("name"));
Upvotes: 3