Class SQLiteCursor
-
- 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 intPREFERRED_CURSOR_WINDOW_SIZEpublic final static intFIELD_TYPE_BLOBpublic final static intFIELD_TYPE_FLOATpublic final static intFIELD_TYPE_INTEGERpublic final static intFIELD_TYPE_NULLpublic final static intFIELD_TYPE_STRING
-
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 Cursor interface. SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query)Execute a query and provide access to its result set through a Cursor interface.
-
Method Summary
Modifier and Type Method Description SQLiteDatabasegetDatabase()Get the database that this cursor is associated with. booleanonMove(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. intgetCount()static voidsetCursorWindowSize(int size)static voidresetCursorWindowSize()intgetColumnIndex(String columnName)Array<String>getColumnNames()voiddeactivate()voidclose()booleanrequery()voidsetWindow(CursorWindow window)Sets a new cursor window for the cursor to use. voidsetSelectionArguments(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 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 fromFROMonward would be in the params argument.- Parameters:
db- a reference to a Database object that is already constructed and opened.editTable- the name of the table used for this queryquery- the rest of the query terms cursor is finalized
-
SQLiteCursor
SQLiteCursor(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 fromFROMonward would be in the params argument.- 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.
- Returns:
the SQLiteDatabase that this cursor is associated with.
-
onMove
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. If it returns false the move function will also do so and the cursor 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.- Returns:
True if the move is successful, false otherwise.
-
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 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.
- 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().
-
-
-
-