Code example for Cursor

Methods: closedeactivategetCountrequery

0
    public void testRequery() throws Exception { 
        populateDefaultTable(); 
 
        Cursor c = mDatabase.rawQuery("SELECT * FROM test", null);
        assertNotNull(c);
        assertEquals(3, c.getCount());
        c.deactivate();
        c.requery();
        assertEquals(3, c.getCount());
        c.close();
    } 
 
    @MediumTest 
    public void testRequeryWithSelection() throws Exception { 
        populateDefaultTable(); 
 
        Cursor c = mDatabase.rawQuery("SELECT data FROM test WHERE data = '" + sString1 + "'",
                null); 
        assertNotNull(c);
        assertEquals(1, c.getCount());
        assertTrue(c.moveToFirst());