Remove value from cursor android

For a particular reason I am adding a dummy content to my cursor. But after user have performed some actions I want to remove that dummy content I have added to the cursor. Is there an option to do so?

https://stackoverflow.com/a/18154738/14705856, This was one of the solutions that I found on SO. But the issue is that the table I am using has lot of columns. So is there any way to copy all the row values instead of adding them as cursor.getString(columnPosition).

   String exclueRef = "Some id to exclude for the new";
   MatrixCursor newCursor = new MatrixCursor(new String[] {"column A", "column B");
         if (cursor.moveToFirst()) {
            do {
                // skip the copy of this one .... 
                if (cursor.getString(0).equals(exclueRef))
                    continue;
                newCursor.addRow(new Object[]{cursor.getString(0), cursor.getString(1)});
            } while (cursor.moveToNext());
        }

Source: Android Questions

LEAVE A COMMENT