Java Code Examples for android.database.MatrixCursor#getColumnNames()

The following examples show how to use android.database.MatrixCursor#getColumnNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataUtilsTest.java    From arca-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void testGetCursorWithNullList() throws Exception {
    final MatrixCursor cursor = DataUtils.getCursor(null);

    final String[] columnNames = cursor.getColumnNames();

    assertEquals(1, columnNames.length);
    assertEquals(columnNames[0], "_id");
}
 
Example 2
Source File: DataUtilsTest.java    From arca-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void testGetCursorWithEmptyList() throws Exception {
    final MatrixCursor cursor = DataUtils.getCursor(new ArrayList<Object>());

    final String[] columnNames = cursor.getColumnNames();

    assertEquals(1, columnNames.length);
    assertEquals(columnNames[0], "_id");
}
 
Example 3
Source File: DataUtilsTest.java    From arca-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void testGetCursorReturnsAppropriateCursor() throws Exception {

        final List<SimpleModel> models = new ArrayList<SimpleModel>();
        models.add(new SimpleModel("id0", "title0"));
        models.add(new SimpleModel("id1", "title1"));
        models.add(new SimpleModel("id2", "title2"));

        final MatrixCursor cursor = DataUtils.getCursor(models);
        final String[] columnNames = cursor.getColumnNames();

        assertEquals(3, columnNames.length);
        assertEquals(columnNames[0], "_id");
        assertEquals(columnNames[1], "mId");
        assertEquals(columnNames[2], "mTitle");

        cursor.moveToPosition(0);

        assertEquals("0", cursor.getString(0));
        assertEquals("id0", cursor.getString(1));
        assertEquals("title0", cursor.getString(2));

        cursor.moveToPosition(1);

        assertEquals("1", cursor.getString(0));
        assertEquals("id1", cursor.getString(1));
        assertEquals("title1", cursor.getString(2));

        cursor.moveToPosition(2);

        assertEquals("2", cursor.getString(0));
        assertEquals("id2", cursor.getString(1));
        assertEquals("title2", cursor.getString(2));
    }
 
Example 4
Source File: DataUtilsTest.java    From arca-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void testGetCursorReturnsAppropriateCursorWithAnnotatedModel() throws Exception {

        final List<AnnotatedModel> models = new ArrayList<AnnotatedModel>();
        models.add(new AnnotatedModel("id0", "title0"));
        models.add(new AnnotatedModel("id1", "title1"));
        models.add(new AnnotatedModel("id2", "title2"));

        final MatrixCursor cursor = DataUtils.getCursor(models);
        final String[] columnNames = cursor.getColumnNames();

        assertEquals(3, columnNames.length);
        assertEquals(columnNames[0], "_id");
        assertEquals(columnNames[1], "id");
        assertEquals(columnNames[2], "title");

        cursor.moveToPosition(0);

        assertEquals("0", cursor.getString(0));
        assertEquals("id0", cursor.getString(1));
        assertEquals("title0", cursor.getString(2));

        cursor.moveToPosition(1);

        assertEquals("1", cursor.getString(0));
        assertEquals("id1", cursor.getString(1));
        assertEquals("title1", cursor.getString(2));

        cursor.moveToPosition(2);

        assertEquals("2", cursor.getString(0));
        assertEquals("id2", cursor.getString(1));
        assertEquals("title2", cursor.getString(2));
    }