public class SQLiteCursor extends AbstractWindowedCursor
SQLiteDatabase
.
SQLiteCursor is not internally synchronized so code using a SQLiteCursor from multiple
threads should perform its own synchronization when using the SQLiteCursor.AbstractCursor.SelfContentObserver
mWindow
mClosed, mContentResolver, mCurrentRowID, mPos, mRowIdColumnIndex, mUpdatedRows
FIELD_TYPE_BLOB, FIELD_TYPE_FLOAT, FIELD_TYPE_INTEGER, FIELD_TYPE_NULL, FIELD_TYPE_STRING
Constructor and Description |
---|
SQLiteCursor(SQLiteCursorDriver driver,
String editTable,
SQLiteQuery query)
Execute a query and provide access to its result set through a Cursor
interface.
|
SQLiteCursor(SQLiteDatabase db,
SQLiteCursorDriver driver,
String editTable,
SQLiteQuery query)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the Cursor, releasing all of its resources and making it completely invalid.
|
void |
deactivate()
Deactivates the Cursor, making all calls on it fail until
Cursor.requery() is called. |
protected void |
finalize()
Release the native resources, if they haven't been released yet.
|
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()
Get the database that this cursor is associated with.
|
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.
|
boolean |
requery()
Performs the query that created the cursor again, refreshing its
contents.
|
void |
setSelectionArguments(String[] selectionArgs)
Changes the selection arguments.
|
void |
setWindow(CursorWindow window)
Sets a new cursor window for the cursor to use.
|
checkPosition, clearOrCreateWindow, closeWindow, copyStringToBuffer, getBlob, getDouble, getFloat, getInt, getLong, getShort, getString, getType, getWindow, hasWindow, isBlob, isFloat, isLong, isNull, isString, onDeactivateOrClose
fillWindow, getColumnCount, getColumnIndexOrThrow, getColumnName, getExtras, getNotificationUri, getPosition, getUpdatedField, getWantsAllOnMoveCalls, isAfterLast, isBeforeFirst, isClosed, isFieldUpdated, isFirst, isLast, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, onChange, registerContentObserver, registerDataSetObserver, respond, setExtras, setNotificationUri, setNotificationUri, unregisterContentObserver, unregisterDataSetObserver
@Deprecated public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query)
SQLiteCursor(SQLiteCursorDriver, String, SQLiteQuery)
insteadSELECT 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 from
FROM
onward would be in the params argument.db
- a reference to a Database object that is already constructed
and opened. This param is not used any longereditTable
- the name of the table used for this queryquery
- the rest of the query terms
cursor is finalizedpublic SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query)
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 from
FROM
onward would be in the params argument.editTable
- the name of the table used for this queryquery
- the SQLiteQuery
object associated with this cursor object.public SQLiteDatabase getDatabase()
public boolean onMove(int oldPosition, int newPosition)
AbstractCursor
onMove
in interface CrossProcessCursor
onMove
in class AbstractCursor
oldPosition
- the position that we're moving fromnewPosition
- the position that we're moving topublic int getCount()
Cursor
getCount
in interface Cursor
getCount
in class AbstractCursor
public int getColumnIndex(String columnName)
Cursor
Cursor.getColumnIndexOrThrow(String)
instead, which
will make the error more clear.getColumnIndex
in interface Cursor
getColumnIndex
in class AbstractCursor
columnName
- the name of the target column.Cursor.getColumnIndexOrThrow(String)
public String[] getColumnNames()
Cursor
getColumnNames
in interface Cursor
getColumnNames
in class AbstractCursor
public void deactivate()
Cursor
Cursor.requery()
is called.
Inactive Cursors use fewer resources than active Cursors.
Calling Cursor.requery()
will make the cursor active again.deactivate
in interface Cursor
deactivate
in class AbstractCursor
public void close()
Cursor
Cursor.deactivate()
a call to Cursor.requery()
will not make the Cursor valid
again.close
in interface Cursor
close
in interface Closeable
close
in interface AutoCloseable
close
in class AbstractCursor
public boolean requery()
Cursor
Cursor.deactivate()
.
Since this method could execute a query on the database and potentially take
a while, it could cause ANR if it is called on Main (UI) thread.
A warning is printed if this method is being executed on Main thread.requery
in interface Cursor
requery
in class AbstractCursor
public void setWindow(CursorWindow window)
AbstractWindowedCursor
The cursor takes ownership of the provided cursor window; the cursor window will be closed when the cursor is closed or when the cursor adopts a new cursor window.
If the cursor previously had a cursor window, then it is closed when the new cursor window is assigned.
setWindow
in class AbstractWindowedCursor
window
- The new cursor window, typically a remote cursor window.public void setSelectionArguments(String[] selectionArgs)
protected void finalize()
finalize
in class AbstractCursor