public class

MergeCursor

extends AbstractCursor
java.lang.Object
   ↳ android.database.AbstractCursor
     ↳ android.database.MergeCursor

Class Overview

A convience class that lets you present an array of Cursors as a single linear Cursor. The schema of the cursors presented is entirely up to the creator of the MergeCursor, and may be different if that is desired. Calls to getColumns, getColumnIndex, etc will return the value for the row that the MergeCursor is currently pointing at.

Summary

[Expand]
Inherited Fields
From class android.database.AbstractCursor
Public Constructors
MergeCursor(Cursor[] cursors)
Public Methods
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 requery() is called.
byte[] getBlob(int column)
Returns the value of the requested column as a byte array.
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.
double getDouble(int column)
Returns the value of the requested column as a double.
float getFloat(int column)
Returns the value of the requested column as a float.
int getInt(int column)
Returns the value of the requested column as an int.
long getLong(int column)
Returns the value of the requested column as a long.
short getShort(int column)
Returns the value of the requested column as a short.
String getString(int column)
Returns the value of the requested column as a String.
boolean isNull(int column)
Returns true if the value in the indicated column is null.
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.
void registerContentObserver(ContentObserver observer)
Register an observer that is called when changes happen to the content backing this cursor.
void registerDataSetObserver(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 requery(), deactivate(), or close().
boolean requery()
Performs the query that created the cursor again, refreshing its contents.
void unregisterContentObserver(ContentObserver observer)
Unregister an observer that has previously been registered with this cursor via registerContentObserver(ContentObserver).
void unregisterDataSetObserver(DataSetObserver observer)
Unregister an observer that has previously been registered with this cursor via registerContentObserver(ContentObserver).
[Expand]
Inherited Methods
From class android.database.AbstractCursor
From class java.lang.Object
From interface android.database.CrossProcessCursor
From interface android.database.Cursor

Public Constructors

public MergeCursor (Cursor[] cursors)

Public Methods

public void close ()

Closes the Cursor, releasing all of its resources and making it completely invalid. Unlike deactivate() a call to requery() will not make the Cursor valid again.

public void deactivate ()

Deactivates the Cursor, making all calls on it fail until requery() is called. Inactive Cursors use fewer resources than active Cursors. Calling requery() will make the cursor active again.

public byte[] getBlob (int column)

Returns the value of the requested column as a byte array.

If the native content of that column is not blob exception may throw

Parameters
column the zero-based index of the target column.
Returns
  • the value of that column as a byte array.

public 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.

Returns
  • the names of the columns returned in this query.

public int getCount ()

Returns the numbers of rows in the cursor.

Returns
  • the number of rows in the cursor.

public double getDouble (int column)

Returns the value of the requested column as a double.

If the native content of that column is not numeric the result will be the result of passing the column value to Double.valueOf(x).

Parameters
column the zero-based index of the target column.
Returns
  • the value of that column as a double.

public float getFloat (int column)

Returns the value of the requested column as a float.

If the native content of that column is not numeric the result will be the result of passing the column value to Float.valueOf(x).

Parameters
column the zero-based index of the target column.
Returns
  • the value of that column as a float.

public int getInt (int column)

Returns the value of the requested column as an int.

If the native content of that column is not numeric the result will be the result of passing the column value to Integer.valueOf(x).

Parameters
column the zero-based index of the target column.
Returns
  • the value of that column as an int.

public long getLong (int column)

Returns the value of the requested column as a long.

If the native content of that column is not numeric the result will be the result of passing the column value to Long.valueOf(x).

Parameters
column the zero-based index of the target column.
Returns
  • the value of that column as a long.

public short getShort (int column)

Returns the value of the requested column as a short.

If the native content of that column is not numeric the result will be the result of passing the column value to Short.valueOf(x).

Parameters
column the zero-based index of the target column.
Returns
  • the value of that column as a short.

public String getString (int column)

Returns the value of the requested column as a String.

If the native content of that column is not text the result will be the result of passing the column value to String.valueOf(x).

Parameters
column the zero-based index of the target column.
Returns
  • the value of that column as a String.

public boolean isNull (int column)

Returns true if the value in the indicated column is null.

Parameters
column the zero-based index of the target column.
Returns
  • whether the column value is null.

public 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.

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

public void registerContentObserver (ContentObserver observer)

Register an observer that is called when changes happen to the content backing this cursor. Typically the data set won't change until requery() is called.

Parameters
observer the object that gets notified when the content backing the cursor changes.

public void registerDataSetObserver (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 requery(), deactivate(), or close().

Parameters
observer the object that gets notified when the cursors data set changes.

public boolean requery ()

Performs the query that created the cursor again, refreshing its contents. This may be done at any time, including after a call to deactivate().

Returns
  • true if the requery succeeded, false if not, in which case the cursor becomes invalid.

public void unregisterContentObserver (ContentObserver observer)

Unregister an observer that has previously been registered with this cursor via registerContentObserver(ContentObserver).

Parameters
observer the object to unregister.

public void unregisterDataSetObserver (DataSetObserver observer)

Unregister an observer that has previously been registered with this cursor via registerContentObserver(ContentObserver).

Parameters
observer the object to unregister.