更新时间:2023-11-06 22:27:34
您需要将光标定位到第一行之前,你可以从它那里得到的数据。要做到这一点,你可以拨打: mCursor.moveToFirst()
。此外,该方法调用返回一个布尔值,如果没有结果,这将是虚假的;所以你也可以用它来防止这种情况。
You need to position the Cursor to the first row before you can get data from it. To do this you can call: mCursor.moveToFirst()
. Also, this method call returns a boolean, which will be false if there are no results; so you can also use it to guard against that case.
如果您需要通过多个结果迭代,然后调用后 mCursor.moveToFirst()
,您可以使用 mCursor.moveToNext()
方法,通过结果行一个接一个。再次,当它到达的数据集的结尾这个返回false。
If you need to iterate through multiple results, then after calling mCursor.moveToFirst()
, you can use the mCursor.moveToNext()
method go through the result rows one by one. Once again, this returns false when it reaches the end of the data set.
希望是有道理的。