String selectQuery = "SELECT accno from AccountMaster where pan = " + pan;
Cursor cursor = db.rawQuery(selectQuery, null);
int accno = 0;
if(cursor.moveToFirst())
accno=cursor.getInt(0);
答案 0 :(得分:1)
首先,您必须确保要获取的列存储文本。在那种情况下使用
String selectQuery = "SELECT accno from AccountMaster where pan = " + pan;
Cursor cursor = db.rawQuery(selectQuery, null);
if(cursor.moveToFirst()){
String value = cursor.getString(indexNumber)
}
否则,如果列存储了int,则可以执行此操作。
String selectQuery = "SELECT accno from AccountMaster where pan = " + pan;
Cursor cursor = db.rawQuery(selectQuery, null);
if(cursor.moveToFirst()){
int value = cursor.getInt(indexNumber)
}
您也可以使用
将返回的int值转换为String值String mValue = String.valueOf(intValue);