use of android.database.CursorIndexOutOfBoundsException in project newsrob by marianokamp.
the class DashboardListActivity method onContextItemSelected.
@Override
protected boolean onContextItemSelected(MenuItem item, int selectedPosition) {
String label = null;
int ord = -99;
try {
Cursor c = (Cursor) sca.getItem(selectedPosition);
label = c.getString(0);
ord = c.getInt(3);
} catch (CursorIndexOutOfBoundsException cioobe) {
// label stays null
}
if (label == null)
return false;
if (item.getItemId() == MENU_ITEM_MARK_ALL_READ_ID) {
boolean showOnlyNotes = ord == -7 && "notes".equals(label);
Long feedId = null;
if (showOnlyNotes) {
feedId = getEntryManager().findNotesFeedId();
label = null;
}
DBQuery dbq = getDbQuery();
instantiateMarkAllReadDialog(label, feedId, dbq.getStartDate(), dbq.getDateLimit(), dbq.isSortOrderAscending(), dbq.getLimit());
}
// getEntryManager().requestMarkAllAsRead(label, null, 0, handler);
return true;
}
use of android.database.CursorIndexOutOfBoundsException in project android_frameworks_base by crdroidandroid.
the class DatabaseCursorTest method testCursor1.
@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");
assertEquals(dataColumn, dataColumn2);
assertSame(3, c.getCount());
assertTrue(c.isBeforeFirst());
try {
c.getInt(0);
fail("CursorIndexOutOfBoundsException expected");
} catch (CursorIndexOutOfBoundsException ex) {
// expected
}
c.moveToNext();
assertEquals(1, c.getInt(0));
String s = c.getString(dataColumn);
assertEquals(sString1, s);
c.moveToNext();
s = c.getString(dataColumn);
assertEquals(sString2, s);
c.moveToNext();
s = c.getString(dataColumn);
assertEquals(sString3, s);
c.moveToPosition(-1);
c.moveToNext();
s = c.getString(dataColumn);
assertEquals(sString1, s);
c.moveToPosition(2);
s = c.getString(dataColumn);
assertEquals(sString3, s);
int i;
for (c.moveToFirst(), i = 0; !c.isAfterLast(); c.moveToNext(), i++) {
c.getInt(0);
}
assertEquals(3, i);
try {
c.getInt(0);
fail("CursorIndexOutOfBoundsException expected");
} catch (CursorIndexOutOfBoundsException ex) {
// expected
}
c.close();
}
Aggregations