Code example for MergeCursor

Methods: getCountmoveToFirst

2
		Cursor level2 = mDb.rawQuery("select q._id,q.lesson_id, q.text, q.explain, q.level, q.max_points, q.created, q.modified from questions q, lessons l, subjects s " +
				"where  s._id=l.subject_id and q.lesson_id =l._id and s._id=? and q.level=2 order by random() limit 6 ", new String[]{String.valueOf(subId)});
		Cursor level3 = mDb.rawQuery("select q._id,q.lesson_id, q.text, q.explain, q.level, q.max_points, q.created, q.modified from questions q, lessons l, subjects s " +
				"where  s._id=l.subject_id and q.lesson_id =l._id and s._id=? and q.level=3 order by random() limit 4 ", new String[]{String.valueOf(subId)});
		 
		Cursor merCur = new MergeCursor(new Cursor[]{level1,level2,level3});
		if (merCur.getCount() <1) {
    		return null; 
    	} 
		merCur.moveToFirst();
		 
		return merCur;
		 
	} 
     
     
    /** 
     * Update the Question using the details provided. The Question to be updated is 
     * specified using the rowId, and it is altered to use the lesson_id, text, explain, level, max_points, done, created, modified and rowId 
     * values passed in 
     *