Android examples for Database:Cursor
Create MatrixCursor From Cursor
//package com.java2s; import android.database.Cursor; import android.database.MatrixCursor; public class Main { public static MatrixCursor matrixCursorFromCursor(Cursor cursor) { if (cursor == null) { return null; }//w ww .ja v a 2 s . co m String[] columnNames = cursor.getColumnNames(); if (columnNames == null) { columnNames = new String[] {}; } MatrixCursor newCursor = new MatrixCursor(columnNames); int numColumns = cursor.getColumnCount(); String data[] = new String[numColumns]; cursor.moveToPosition(-1); while (cursor.moveToNext()) { for (int i = 0; i < numColumns; i++) { data[i] = cursor.getString(i); } newCursor.addRow(data); } return newCursor; } }