I have an array of phone numbers and I want to get the corresponding contact names from the contacts database.
In the array of phone numbers, I also have some number
Easiest way to add rows in a cursor is to use a MatrixCursor and a MergeCursor. Those two classes are from the SDK and here to solve that kind of problems.
Basically what you do is :
MatrixCusrorcursor and your matrixCursor using a MergeCursorSomething like:
// Create a MatrixCursor filled with the rows you want to add.
MatrixCursor matrixCursor = new MatrixCursor(new String[] { colName1, colName2 });
matrixCursor.addRow(new Object[] { value1, value2 });
// Merge your existing cursor with the matrixCursor you created.
MergeCursor mergeCursor = new MergeCursor(new Cursor[] { matrixCursor, cursor });
// Use your the mergeCursor as you would use your cursor.