出处:http://www.apihome.cn/api/android/SQLiteCursor.html
android.database.sqlite
类 SQLiteCursor
java.lang.Object
android.database.AbstractCursor
android.database.AbstractWindowedCursor
android.database.sqlite.SQLiteCursor
-
所有已实现的接口:
- CrossProcessCursor, Cursor
public class SQLiteCursor extends AbstractWindowedCursor
A Cursor implementation that exposes results from a query on a SQLiteDatabase.
构造方法摘要 | |
---|---|
SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) Execute a query and provide access to its result set through a Cursor interface. |
方法摘要 | |
---|---|
void | close() Closes the Cursor, releasing all of its resources and making it completely invalid. |
boolean | commitUpdates(Map<? extends Long,? extends Map<String,Object>> additionalValues) 已过时。 |
void | deactivate() Deactivates the Cursor, making all calls on it fail until Cursor.requery() is called. |
boolean | deleteRow() 已过时。 |
int | getColumnIndex(String columnName) Returns the zero-based index for the given column name, or -1 if the column doesn't exist. |
String[] | getColumnNames() Returns a string array holding the names of all of the columns in the result set in the order in which they were listed in the result. |
int | getCount() Returns the numbers of rows in the cursor. |
SQLiteDatabase | getDatabase() |
boolean | onMove(int oldPosition, int newPosition) This function is called every time the cursor is successfully scrolled to a new position, giving the subclass a chance to update any state it may have. |
void | registerDataSetObserver(DataSetObserver observer) Register an observer that is called when changes happen to the contents of the this cursors data set, for example, when the data set is changed via Cursor.requery(), Cursor.deactivate(), or Cursor.close(). |
boolean | requery() Performs the query that created the cursor again, refreshing its contents. |
void | setLoadStyle(int initialRead, int maxRead) support for a cursor variant that doesn't always read all results initialRead is the initial number of items that cursor window reads if query contains more than this number of items, a thread will be created and handle the left over items so that caller can show results as soon as possible |
void | setSelectionArguments(String[] selectionArgs) Changes the selection arguments. |
void | setWindow(CursorWindow window) Set a new cursor window to cursor, usually set a remote cursor window |
boolean | supportsUpdates() 已过时。 |
从类 android.database.AbstractWindowedCursor 继承的方法 |
---|
copyStringToBuffer, getBlob, getDouble, getFloat, getInt, getLong, getShort, getString, getWindow, hasWindow, isBlob, isNull |
从类 android.database.AbstractCursor 继承的方法 |
---|
abortUpdates, commitUpdates, deactivateInternal, fillWindow, getColumnCount, getColumnIndexOrThrow, getColumnName, getExtras, getPosition, getWantsAllOnMoveCalls, hasUpdates, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, registerContentObserver, respond, setNotificationUri, unregisterContentObserver, unregisterDataSetObserver, update, updateBlob, updateDouble, updateFloat, updateInt, updateLong, updateShort, updateString, updateToNull |
从类 java.lang.Object 继承的方法 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
构造方法详细信息 |
---|
SQLiteCursor
public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query)
-
Execute a query and provide access to its result set through a Cursor interface. For a query such as:
SELECT name, birth, phone FROM myTable WHERE ... LIMIT 1,20 ORDER BY...
the column names (name, birth, phone) would be in the projection argument and everything fromFROM
onward would be in the params argument. This constructor has package scope.-
参数:
-
db
- a reference to a Database object that is already constructed and opened -
editTable
- the name of the table used for this query -
query
- the rest of the query terms cursor is finalized
-
方法详细信息 |
---|
setLoadStyle
public void setLoadStyle(int initialRead, int maxRead)
-
support for a cursor variant that doesn't always read all results initialRead is the initial number of items that cursor window reads if query contains more than this number of items, a thread will be created and handle the left over items so that caller can show results as soon as possible
-
-
参数:
-
initialRead
- initial number of items that cursor read -
maxRead
- leftover items read at maxRead items per time
-
registerDataSetObserver
public void registerDataSetObserver(DataSetObserver observer)
-
从接口
Cursor
复制的描述 -
Register an observer that is called when changes happen to the contents of the this cursors data set, for example, when the data set is changed via Cursor.requery(), Cursor.deactivate(), or Cursor.close().
-
-
指定者:
-
接口
Cursor
中的registerDataSetObserver
覆盖:
-
类
AbstractCursor
中的registerDataSetObserver
-
接口
-
-
参数:
-
observer
- the object that gets notified when the cursors data set changes.
另请参见:
- Cursor.unregisterDataSetObserver(DataSetObserver)
-
getDatabase
public SQLiteDatabase getDatabase()
-
-
返回:
- the SQLiteDatabase that this cursor is associated with.
onMove
public boolean onMove(int oldPosition, int newPosition)
-
从类
AbstractCursor
复制的描述 -
This function is called every time the cursor is successfully scrolled to a new position, giving the subclass a chance to update any state it may have. If it returns false the move function will also do so and the cursor will scroll to the beforeFirst position.
-
-
指定者:
-
接口
CrossProcessCursor
中的onMove
覆盖:
-
类
AbstractCursor
中的onMove
-
接口
-
-
参数:
-
oldPosition
- the position that we're moving from -
newPosition
- the position that we're moving to
返回:
- true if the move is successful, false otherwise
-
getCount
public int getCount()
-
从接口
Cursor
复制的描述 -
Returns the numbers of rows in the cursor.
-
-
指定者:
-
接口
Cursor
中的getCount
指定者:
-
类
AbstractCursor
中的getCount
-
接口
-
-
返回:
- the number of rows in the cursor.
getColumnIndex
public int getColumnIndex(String columnName)
-
从接口
Cursor
复制的描述 -
Returns the zero-based index for the given column name, or -1 if the column doesn't exist. If you expect the column to exist use Cursor.getColumnIndexOrThrow(String) instead, which will make the error more clear.
-
-
指定者:
-
接口
Cursor
中的getColumnIndex
覆盖:
-
类
AbstractCursor
中的getColumnIndex
-
接口
-
-
参数:
-
columnName
- the name of the target column.
返回:
- the zero-based column index for the given column name, or -1 if the column name does not exist. 另请参见:
- Cursor.getColumnIndexOrThrow(String)
-
deleteRow
public boolean deleteRow()
-
已过时。
-
从接口
Cursor
复制的描述 -
Removes the row at the current cursor position from the underlying data store. After this method returns the cursor will be pointing to the row after the row that is deleted. This has the side effect of decrementing the result of count() by one.
The query must have the row ID column in its selection, otherwise this call will fail.
-
-
指定者:
-
接口
Cursor
中的deleteRow
覆盖:
-
类
AbstractCursor
中的deleteRow
-
接口
-
-
返回:
- whether the record was successfully deleted.
getColumnNames
public String[] getColumnNames()
-
从接口
Cursor
复制的描述 -
Returns a string array holding the names of all of the columns in the result set in the order in which they were listed in the result.
-
-
指定者:
-
接口
Cursor
中的getColumnNames
指定者:
-
类
AbstractCursor
中的getColumnNames
-
接口
-
-
返回:
- the names of the columns returned in this query.
supportsUpdates
public boolean supportsUpdates()
-
已过时。
-
从接口
Cursor
复制的描述 -
Returns
true
if the cursor supports updates. -
-
指定者:
-
接口
Cursor
中的supportsUpdates
覆盖:
-
类
AbstractCursor
中的supportsUpdates
-
接口
-
-
返回:
- whether the cursor supports updates.
commitUpdates
public boolean commitUpdates(Map<? extends Long,? extends Map<String,Object>> additionalValues)
-
已过时。
-
从接口
Cursor
复制的描述 -
Atomically commits all updates to the backing store, as well as the updates included in values. After completion, this method leaves the data in an inconsistent state and you should call Cursor.requery() before reading data from the cursor again.
-
-
指定者:
-
接口
Cursor
中的commitUpdates
覆盖:
-
类
AbstractCursor
中的commitUpdates
-
接口
-
-
参数:
-
additionalValues
- A map from row IDs to Maps associating column names with updated values. A null value indicates the field should be removed.
返回:
- whether the operation succeeded.
-
deactivate
public void deactivate()
-
从接口
Cursor
复制的描述 -
Deactivates the Cursor, making all calls on it fail until Cursor.requery() is called. Inactive Cursors use fewer resources than active Cursors. Calling Cursor.requery() will make the cursor active again.
-
-
指定者:
-
接口
Cursor
中的deactivate
覆盖:
-
类
AbstractCursor
中的deactivate
-
接口
-
close
public void close()
-
从接口
Cursor
复制的描述 -
Closes the Cursor, releasing all of its resources and making it completely invalid. Unlike Cursor.deactivate() a call to Cursor.requery() will not make the Cursor valid again.
-
-
指定者:
-
接口
Cursor
中的close
覆盖:
-
类
AbstractCursor
中的close
-
接口
-
requery
public boolean requery()
-
从接口
Cursor
复制的描述 -
Performs the query that created the cursor again, refreshing its contents. This may be done at any time, including after a call to Cursor.deactivate().
-
-
指定者:
-
接口
Cursor
中的requery
覆盖:
-
类
AbstractCursor
中的requery
-
接口
-
-
返回:
- true if the requery succeeded, false if not, in which case the cursor becomes invalid.
setWindow
public void setWindow(CursorWindow window)
-
从类
AbstractWindowedCursor
复制的描述 -
Set a new cursor window to cursor, usually set a remote cursor window
-
-
覆盖:
-
类
AbstractWindowedCursor
中的setWindow
-
类
-
-
参数:
-
window
- cursor window
-
setSelectionArguments
public void setSelectionArguments(String[] selectionArgs)
- Changes the selection arguments. The new values take effect after a call to requery().