Androin学习笔记五十二: SQLiteCursor(示例,出错代码)

出处: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.
 
方法摘要
 voidclose() 
          Closes the Cursor, releasing all of its resources and making it completely invalid.
 booleancommitUpdates(Map<? extends Long,? extends Map<String,Object>> additionalValues) 
          已过时。  
 voiddeactivate() 
          Deactivates the Cursor, making all calls on it fail until Cursor.requery() is called.
 booleandeleteRow() 
          已过时。  
 intgetColumnIndex(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.
 intgetCount() 
          Returns the numbers of rows in the cursor.
 SQLiteDatabasegetDatabase() 
           
 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.
 voidregisterDataSetObserver(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().
 booleanrequery() 
          Performs the query that created the cursor again, refreshing its contents.
 voidsetLoadStyle(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
 voidsetSelectionArguments(String[] selectionArgs) 
          Changes the selection arguments.
 voidsetWindow(CursorWindow window) 
          Set a new cursor window to cursor, usually set a remote cursor window
 booleansupportsUpdates() 
          已过时。  
 
从类 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 from  FROM 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().

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值