Abdellah Abdellah - 5 months ago 7
Android Question

It's possible to append Cursors?

I'm looking to add the content of an

Cursor
to an existing
Cursor
.

Answer

Yes as @njzk2 already suggested you can use a MergeCursor like this:

final Cursor mergedCursor = new MergeCursor(new Cursor[] {
        firstCursor,
        secondCursor
});

After that you can use the merged Cursor like you would use any other. getColumn() and getColumnIndex will return the values of the item at the current position. Here you can find some documentation.

Of course you can always JOIN tables or use UNION in your SQL queries.

Comments