Code example for Cursor

Methods: closegetDoublemoveToFirst

0
        values.put("data", 42.11);
        long id = mDatabase.insert("test", "data", values);
        assertTrue(id > 0);
        Cursor c = mDatabase.rawQuery("SELECT data FROM test", null);
        assertNotNull(c);
        assertTrue(c.moveToFirst());
        assertEquals(42.11, c.getDouble(0));
        c.close();
    } 
 
    @MediumTest 
    public void testCursor1() throws Exception { 
        populateDefaultTable(); 
 
        Cursor c = mDatabase.query("test", null, null, null, null, null, null);
 
        int dataColumn = c.getColumnIndexOrThrow("data");
 
        // The cursor should ignore text before the last period when looking for a column. (This 
        // is a temporary hack in all implementations of getColumnIndex.) 
        int dataColumn2 = c.getColumnIndexOrThrow("junk.data");