/** * Prints the contents of a Cursor to a StringBuilder. The position is restored after printing. * * @param cursor the cursor to print * @param sb the StringBuilder to print to */ public static void dumpCursor(Cursor cursor, StringBuilder sb) { sb.append(">>>>> Dumping cursor " + cursor + "\n"); if (cursor != null) { int startPos = cursor.getPosition(); cursor.moveToPosition(-1); while (cursor.moveToNext()) { dumpCurrentRow(cursor, sb); } cursor.moveToPosition(startPos); } sb.append("<<<<<\n"); }
/** * Prints the contents of a Cursor to a PrintSteam. The position is restored after printing. * * @param cursor the cursor to print * @param stream the stream to print to */ public static void dumpCursor(Cursor cursor, PrintStream stream) { stream.println(">>>>> Dumping cursor " + cursor); if (cursor != null) { int startPos = cursor.getPosition(); cursor.moveToPosition(-1); while (cursor.moveToNext()) { dumpCurrentRow(cursor, stream); } cursor.moveToPosition(startPos); } stream.println("<<<<<"); }
/** * Dump the contents of a Cursor's current row to a String. * * @param cursor the cursor to print * @return a String that contains the dumped cursor row */ public static String dumpCurrentRowToString(Cursor cursor) { StringBuilder sb = new StringBuilder(); dumpCurrentRow(cursor, sb); return sb.toString(); }
/** * Prints the contents of a Cursor's current row to System.out. * * @param cursor the cursor to print from */ public static void dumpCurrentRow(Cursor cursor) { dumpCurrentRow(cursor, System.out); }