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
I know this an old post, but it is a real pain that rows can not be added manually to a Cursor. I have come up with a crude solution. It might be of some help.
Cursor is actually an interface and you can create a custom class that implements the Cursor interface.
class ManualCursor implements Cursor{
// ....
private Vector rows;
public void addRow(String[] values){
rows.add(values);
}
// Implement the necessary methods, getString(int), etc.
//....
}
And finally in your code
if (cursors[i].getCount() == 0){
cursors[i] = new ManualCursor();
cursors[i].addRow(rowValues);
}
That should do it. But be warned though, for this to work, you have to be wise while implementing the Cursor interface.