private static ArrayList<String> flattenRows(Cursor cursor,int limit){
  Util.throwIfNot(limit >= 0);
  ArrayList<String> flatList=new ArrayList<>();
  final int numColumns=cursor.getColumnCount();
  for (int row=0; row < limit && cursor.moveToNext(); row++) {
    for (int column=0; column < numColumns; column++) {
switch (cursor.getType(column)) {
case Cursor.FIELD_TYPE_NULL:
        flatList.add(null);
      break;
case Cursor.FIELD_TYPE_INTEGER:
    flatList.add(String.valueOf(cursor.getLong(column)));
  break;
case Cursor.FIELD_TYPE_FLOAT:
flatList.add(String.valueOf(cursor.getDouble(column)));
break;
case Cursor.FIELD_TYPE_BLOB:
flatList.add(blobToString(cursor.getBlob(column)));
break;
case Cursor.FIELD_TYPE_STRING:
default :
flatList.add(cursor.getString(column));
break;
}
}
}
if (!cursor.isAfterLast()) {
for (int column=0; column < numColumns; column++) {
flatList.add("{truncated}");
}
}
return flatList;
}

private static ArrayList < String > flattenRows ( Cursor cursor , int limit ) { Util . throwIfNot ( limit >= 0 ) ; ArrayList < String > flatList = new ArrayList < > ( ) ; final int numColumns = cursor . getColumnCount ( ) ; for ( int row = 0 ; row < limit && cursor . moveToNext ( ) ; row ++ ) { for ( int column = 0 ; column < numColumns ; column ++ ) { switch ( cursor . getType ( column ) ) { case Cursor . FIELD_TYPE_NULL : flatList . add ( null ) ; break ; case Cursor . FIELD_TYPE_INTEGER : flatList . add ( String . valueOf ( cursor . getLong ( column ) ) ) ; break ; case Cursor . FIELD_TYPE_FLOAT : flatList . add ( String . valueOf ( cursor . getDouble ( column ) ) ) ; break ; case Cursor . FIELD_TYPE_BLOB : flatList . add ( blobToString ( cursor . getBlob ( column ) ) ) ; break ; case Cursor . FIELD_TYPE_STRING : default : flatList . add ( cursor . getString ( column ) ) ; break ; } } } if ( ! cursor . isAfterLast ( ) ) { for ( int column = 0 ; column < numColumns ; column ++ ) { flatList . add ( "{truncated}" ) ; } } return flatList ; }
flatten all columns and all rows of a cursor to a single array . the array cannot be interpreted meaningfully without the number of columns .
