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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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 scrolled to a new position, giving the subclass a chance to update any state it may 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 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 from FROM onward 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 query
        query - 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 from FROM onward would be in the params argument.

        Parameters:
        editTable - the name of the table used for this query
        query - 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.

      • 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().