-
- All Implemented Interfaces:
-
android.database.Cursor
,java.io.Closeable
,java.lang.AutoCloseable
public class SQLiteCursor extends AbstractWindowedCursor
A Cursor implementation that exposes results from a query on a SQLiteDatabase. SQLiteCursor is not internally synchronized so code using a SQLiteCursor from multiple threads should perform its own synchronization when using the SQLiteCursor.
-
-
Field Summary
Fields Modifier and Type Field Description public static int
PREFERRED_CURSOR_WINDOW_SIZE
-
Constructor Summary
Constructors Constructor Description SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query)
Execute a query and provide access to its result set through a Cursorinterface. SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query)
Execute a query and provide access to its result set through a Cursorinterface.
-
Method Summary
Modifier and Type Method Description 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 scrolledto a new position, giving the subclass a chance to update any state itmay have. int
getCount()
static void
setCursorWindowSize(int size)
static void
resetCursorWindowSize()
int
getColumnIndex(String columnName)
Array<String>
getColumnNames()
void
deactivate()
void
close()
boolean
requery()
void
setWindow(CursorWindow window)
Sets a new cursor window for the cursor to use. void
setSelectionArguments(Array<String> selectionArgs)
Changes the selection arguments. -
Methods inherited from class net.zetetic.database.AbstractWindowedCursor
copyStringToBuffer, getBlob, getDouble, getFloat, getInt, getLong, getShort, getString, getType, getWindow, hasWindow, isNull
-
Methods inherited from class net.zetetic.database.AbstractCursor
fillWindow, getBlob, getColumnCount, getColumnIndexOrThrow, getColumnName, getDouble, getExtras, getFloat, getInt, getLong, getNotificationUri, getPosition, getShort, getString, getType, getWantsAllOnMoveCalls, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isNull, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, registerContentObserver, registerDataSetObserver, respond, setExtras, setNotificationUri, unregisterContentObserver, unregisterDataSetObserver
-
Methods inherited from class android.database.Cursor
close, copyStringToBuffer, deactivate, getBlob, getColumnCount, getColumnIndex, getColumnIndexOrThrow, getColumnName, getColumnNames, getCount, getDouble, getExtras, getFloat, getInt, getLong, getNotificationUri, getNotificationUris, getPosition, getShort, getString, getType, getWantsAllOnMoveCalls, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isNull, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, registerContentObserver, registerDataSetObserver, requery, respond, setExtras, setNotificationUri, setNotificationUris, unregisterContentObserver, unregisterDataSetObserver
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
SQLiteCursor
SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query)
Execute a query and provide access to its result set through a Cursorinterface.- Parameters:
db
- a reference to a Database object that is already constructedand opened.editTable
- the name of the table used for this queryquery
- the rest of the query termscursor is finalized
-
SQLiteCursor
SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query)
Execute a query and provide access to its result set through a Cursorinterface.- Parameters:
editTable
- the name of the table used for this queryquery
- the SQLiteQuery object associated with this cursor object.
-
-
Method Detail
-
getDatabase
SQLiteDatabase getDatabase()
Get the database that this cursor is associated with.
-
onMove
boolean onMove(int oldPosition, int newPosition)
This function is called every time the cursor is successfully scrolledto a new position, giving the subclass a chance to update any state itmay have. If it returns false the move function will also do so and thecursor will scroll to the beforeFirst position.
This function should be called by methods such as moveToPosition,so it will typically not be called from outside of the cursor class itself.
- Parameters:
oldPosition
- The position that we're moving from.newPosition
- The position that we're moving to.
-
getCount
int getCount()
-
setCursorWindowSize
static void setCursorWindowSize(int size)
-
resetCursorWindowSize
static void resetCursorWindowSize()
-
getColumnIndex
int getColumnIndex(String columnName)
-
getColumnNames
Array<String> getColumnNames()
-
deactivate
void deactivate()
-
close
void close()
-
requery
boolean requery()
-
setWindow
void setWindow(CursorWindow window)
Sets a new cursor window for the cursor to use.
The cursor takes ownership of the provided cursor window; the cursor windowwill be closed when the cursor is closed or when the cursor adopts a newcursor window.
If the cursor previously had a cursor window, then it is closed when thenew cursor window is assigned.
- Parameters:
window
- The new cursor window, typically a remote cursor window.
-
setSelectionArguments
void setSelectionArguments(Array<String> selectionArgs)
Changes the selection arguments. The new values take effect after a call to requery().
-
-
-
-