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.
我已经从任何数据库表中创建了游标。它由_id和相应的名称组成。对于进一步的操作,我需要任何特定的“_id”的“name”值。如何使用光标。
2 个解决方案
#1
3
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"));
#2
0
Very Simple you can get it by either of following way
非常简单,你可以通过以下任何一种方式得到它
String id = cursor.getString( cursor.getColumnIndex("id") ); // id is column name in db
字符串id =游标。getString(cursor.getColumnIndex(" id "));// id是db中的列名。
or
或
String id = cursor.getString( cursor.getColumnIndex(0)); // id is first column in db
字符串id =游标。getString(cursor.getColumnIndex(0));/ id是db中的第一列
#1
3
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"));
#2
0
Very Simple you can get it by either of following way
非常简单,你可以通过以下任何一种方式得到它
String id = cursor.getString( cursor.getColumnIndex("id") ); // id is column name in db
字符串id =游标。getString(cursor.getColumnIndex(" id "));// id是db中的列名。
or
或
String id = cursor.getString( cursor.getColumnIndex(0)); // id is first column in db
字符串id =游标。getString(cursor.getColumnIndex(0));/ id是db中的第一列