您必须在 string final = c.get String(0)
call c.moveToFirst ()
或 c.moveToNext ()
或 或 或 /code> 之前,先隐含地定位于第一行 < / tring(0) < /code> 的位置,然后您才能将 Cursor
移动到第一行,然后从中获取数据 。
<强度 > EDIT: 强度 >
<强>,所以它应该像这样: 强>
if (c.getCount()) { // if there is some data
c.moveToFirst();
String Final = c.getString(0);
}
else {
Toast.makeText(YourActivityName.this, "No data found", Toast.LENGTH_SHORT).show();
}
所以您写道您在 Cursor
的小介绍中工作不好:
If you execute any statement, always instance of Cursor class will be
returned. It s version of a database cursor, it is used in many
database systems.
Class Cursor have following few basic methods:
- getCount() - to get how many rows is in actual cursor
- moveToFirst(), moveToNext() etc. - for moving between rows
- getColumnNames() - to get column names
- getColumnIndex() - to get the zero-based index for the given column
name...
- getString(), getInt() etc. - to get data of requested column index
- requery() - once again execute cursor
- close() - to release resources of cursor.
- and next...
有关光标工作的更多信息,您可以找到 这里
观 观 观