How to Convert ArrayListString to Java Android Cursor

1

how can I do to pass an ArrayList to a cursor with its fields

    
asked by Gerard_jcr 12.08.2016 в 18:28
source

2 answers

1

One option would be using MatrixCursor , adding the values of the ArrayList within the cursor.

MatrixCursor myMatrixCursor = new MatrixCursor(myArrayList.size());
startManagingCursor(myMatrixCursor);  
//Agrega valores de ArrayList en el Cursor.  
matrixCursor.addRow(new Object[] {myArrayList.get(0), myArrayList.get(1), myArrayList.get(2), myArrayList.get(3), ..... });

Then we add the values to the cursor from the created MatrixCursor.

MergeCursor mergeCursor = new MergeCursor(new Cursor[] { matrixCursor, cursor });
    
answered by 12.08.2016 / 19:41
source
0

I think you can use MatrixCursor . It is a Cursor implementation, it is mutable and you can use newRow() to add new rows.

I hope it serves you, sorry I have not tried it.

    
answered by 12.08.2016 в 18:59