android.database.CursorIndexOutOfBoundsException Java Examples
The following examples show how to use
android.database.CursorIndexOutOfBoundsException.
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: RegisteredEventDbAdapter.java From LibreTasks with Apache License 2.0 | 6 votes |
/** * Insert a new RegisteredEvent record given the name of the event and details about the * application. Note that a record with {@code appName} with package name {@code appPackageName} * should exist on the registered application table. * * @param eventName * the name of the event * @param appName * the name of the application associated with the event * @param appPackageName * the package name of the application with the event * @return the primary key id of the new record if successful, -1 otherwise * @throws IllegalArgumentException * if eventName is null or if no application named {@code appName} with package name * {@code appPackageName} does not exist */ public long insert(String eventName, String appName, String appPackageName) { RegisteredAppDbAdapter appDbAdapter = new RegisteredAppDbAdapter(database); Cursor appDbCursor = appDbAdapter.fetchAll(appName, appPackageName, null); /** * Just get the first result. The identifiers used in the query should already be unique enough * that it should just return one record if it existed. */ appDbCursor.moveToFirst(); long appIdPhone; try { appIdPhone = CursorHelper.getLongFromCursor(appDbCursor, RegisteredAppDbAdapter.KEY_APPID); } catch (CursorIndexOutOfBoundsException e) { throw new IllegalArgumentException("Application named" + appName + " with package name " + appPackageName + " does not exist."); } finally { appDbCursor.close(); } return insert(eventName, appIdPhone); }
Example #2
Source File: DatabaseHandler.java From repay-android with Apache License 2.0 | 6 votes |
/** * @return All friends stored in the database as ArrayList * @throws android.database.SQLException */ public ArrayList<Friend> getAllFriends() throws SQLException, NullPointerException, CursorIndexOutOfBoundsException{ SQLiteDatabase db = this.getReadableDatabase(); ArrayList<Friend> friends = new ArrayList<Friend>(); Cursor c = db.query(Names.F_TABLENAME, new String[]{Names.F_REPAYID, Names.F_LOOKUPURI, Names.F_NAME, Names.F_DEBT}, null, null, null, null, null); if (c != null && c.getCount() > 0) { c.moveToFirst(); do { friends.add(new Friend(c.getString(0), c.getString(1), c.getString(2), new BigDecimal(c.getString(3)))); } while (c.moveToNext()); } db.close(); return friends; }
Example #3
Source File: ContactsObserverService.java From Identiconizer with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); if (mMaxContactID == -1) { mConfig = Config.getInstance(getBaseContext()); Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, new String[]{ContactsContract.Contacts._ID}, ContactsContract.Contacts.IN_VISIBLE_GROUP, null, "_id DESC LIMIT 1"); cursor.moveToFirst(); try { mMaxContactID = cursor.getInt(cursor.getColumnIndex("_id")); } catch (CursorIndexOutOfBoundsException e) { mMaxContactID = 0; } cursor.close(); int maxContactID = mConfig.getMaxContactID(); if (mMaxContactID != maxContactID) mConfig.setMaxContactID(mMaxContactID); if (mMaxContactID > maxContactID) startService(new Intent(getApplicationContext(), IdenticonCreationService.class).putExtra("updateExisting", false)); } }
Example #4
Source File: DatabaseHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public PushjetService getService(String token) { SQLiteDatabase db = this.getReadableDatabase(); PushjetService srv; try { Cursor cLsn = db.query(TABLE_SUBSCRIPTION, TABLE_SUBSCRIPTION_KEYS, KEY_SUBSCRIPTION_TOKEN + " = ?", new String[]{token}, null, null, null); cLsn.moveToFirst(); srv = new PushjetService( cLsn.getString(0), cLsn.getString(2), cLsn.getString(3), cLsn.getString(1), new Date((long) cLsn.getInt(4) * 1000) ); } catch (CursorIndexOutOfBoundsException ignore) { srv = new PushjetService(token, "UNKNOWN"); } finally { db.close(); } return srv; }
Example #5
Source File: TicketsAdapter.java From sms-ticket with Apache License 2.0 | 6 votes |
private void deleteTicket(int position) { //SL.get(AnalyticsService.class).trackEvent("delete", "my-tickets"); Cursor cursor = getCursor(); if (cursor == null || cursor.isClosed()) { return; } cursor.moveToPosition(position); long id; try { id = cursor.getLong(iId); } catch (CursorIndexOutOfBoundsException e) { return; } c.getContentResolver().delete(ContentUris.withAppendedId(Tickets.CONTENT_URI, id), null, null); getCursor().requery(); }
Example #6
Source File: PersistableEntries.java From SimpleNews with Apache License 2.0 | 6 votes |
private static Entry loadFromCursor(Cursor cursor) { Entry entry = new Entry(); try { entry.setId(cursor.getLong(0)); entry.setCategoryId(cursor.getLong(1)); entry.setFeedId(cursor.getLong(2)); entry.setTitle(cursor.getString(3)); entry.setDescription(cursor.getString(4)); entry.setDate(cursor.getLong(5)); entry.setSrcName(cursor.getString(6)); entry.setLink(cursor.getString(7)); entry.setShortenedLink(cursor.getString(8)); entry.setImageLink(cursor.getString(9)); entry.setVisible(cursor.getInt(10) == 1); entry.setVisitedDate(cursor.getLong(11)); entry.setFavoriteDate(cursor.getLong(12)); entry.setSeenDate(cursor.getLong(13)); entry.setExpanded(cursor.getInt(13) == 1); } catch (CursorIndexOutOfBoundsException e) { //ignore for this time... } return entry; }
Example #7
Source File: DatabaseHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public PushfishService getService(String token) { SQLiteDatabase db = this.getReadableDatabase(); PushfishService srv; try { Cursor cLsn = db.query(TABLE_SUBSCRIPTION, TABLE_SUBSCRIPTION_KEYS, KEY_SUBSCRIPTION_TOKEN + " = ?", new String[]{token}, null, null, null); cLsn.moveToFirst(); srv = new PushfishService( cLsn.getString(0), cLsn.getString(2), cLsn.getString(3), cLsn.getString(1), new Date((long) cLsn.getInt(4) * 1000) ); } catch (CursorIndexOutOfBoundsException ignore) { srv = new PushfishService(token, "UNKNOWN"); } finally { db.close(); } return srv; }
Example #8
Source File: SimpleGraphObjectCursor.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #9
Source File: SimpleCursor.java From cathode with Apache License 2.0 | 5 votes |
private Object get(int column) { if (column < 0 || column >= columnCount) { throw new CursorIndexOutOfBoundsException( "Requested column: " + column + ", # of columns: " + columnCount); } if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first row."); } if (pos >= data.size()) { throw new CursorIndexOutOfBoundsException("After last row."); } return data.get(pos)[column]; }
Example #10
Source File: SimpleGraphObjectCursor.java From KlyphMessenger with MIT License | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #11
Source File: SimpleGraphObjectCursor.java From Abelana-Android with Apache License 2.0 | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #12
Source File: SimpleGraphObjectCursor.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #13
Source File: SimpleGraphObjectCursor.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #14
Source File: SimpleGraphObjectCursor.java From FacebookImageShareIntent with MIT License | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #15
Source File: SimpleGraphObjectCursor.java From android-skeleton-project with MIT License | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #16
Source File: SimpleGraphObjectCursor.java From barterli_android with Apache License 2.0 | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #17
Source File: SimpleGraphObjectCursor.java From HypFacebook with BSD 2-Clause "Simplified" License | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #18
Source File: ConversationView.java From zom-android-matrix with Apache License 2.0 | 5 votes |
private void checkPosition() { int pos = mInnerCursor.getPosition(); int count = mInnerCursor.getCount(); if (-1 == pos || count == pos) { throw new CursorIndexOutOfBoundsException(pos, count); } }
Example #19
Source File: SimpleGraphObjectCursor.java From Klyph with MIT License | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #20
Source File: DatabaseHandler.java From repay-android with Apache License 2.0 | 5 votes |
/** * Lookup the most recent entry in the database * @return Debt representation of most recent debt entered into database * @throws java.text.ParseException * @throws NullPointerException * @throws android.database.sqlite.SQLiteException * @throws android.database.CursorIndexOutOfBoundsException */ public Debt getMostRecentDebt() throws ParseException, NullPointerException, SQLiteException, CursorIndexOutOfBoundsException{ SQLiteDatabase db = getReadableDatabase(); Cursor c; c = db.query(Names.D_TABLENAME, null, null, null, null, null, null); c.moveToLast(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); db.close(); return new Debt(c.getInt(0), c.getString(1), sdf.parse(c.getString(2)), new BigDecimal(c.getString(2)), c.getString(3)); }
Example #21
Source File: SimpleGraphObjectCursor.java From platform-friends-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
Example #22
Source File: AdapterImpl.java From AsymmetricGridView with MIT License | 5 votes |
@Override protected final List<RowInfo> doInBackground(Void... params) { // We need a map in order to associate the item position in the wrapped adapter. List<RowItem> itemsToAdd = new ArrayList<>(); for (int i = 0; i < agvAdapter.getActualItemCount(); i++) { try { itemsToAdd.add(new RowItem(i, agvAdapter.getItem(i))); } catch (CursorIndexOutOfBoundsException e) { Log.w(TAG, e); } } return calculateItemsPerRow(itemsToAdd); }
Example #23
Source File: SQLiteTileDatabase.java From trekarta with GNU General Public License v3.0 | 5 votes |
protected static String getString(SQLiteDatabase database, String query, String[] args) { try (Cursor c = database.rawQuery(query, args)) { c.moveToFirst(); return c.getString(0); } catch (CursorIndexOutOfBoundsException ignore) { } catch (Throwable e) { e.printStackTrace(); } return null; }
Example #24
Source File: TicketsAdapter.java From sms-ticket with Apache License 2.0 | 5 votes |
/** * Tries to delete ticket either from swipe-to-dismiss or button. * * @return Pair of ticket id and previous status or null if it wasn't deleted. */ public Pair<Long, Integer> archiveTicket(int position) { Cursor cursor = getCursor(); if (cursor == null || cursor.isClosed()) { return null; } cursor.moveToPosition(position); long id; try { id = cursor.getLong(iId); } catch (CursorIndexOutOfBoundsException e) { return null; } final Time validTo = FormatUtil.timeFrom3339(cursor.getString(iValidTo)); int status = getValidityStatus(cursor.getInt(iStatus), validTo); if (status == Tickets.STATUS_EXPIRED) { ContentValues values = new ContentValues(); values.put(TicketProvider.Tickets.STATUS, TicketProvider.Tickets.STATUS_DELETED); c.getContentResolver().update(ContentUris.withAppendedId(TicketProvider.Tickets.CONTENT_URI, id), values, null, null); // I had to call this deprecated method, because it needs to run synchronously. In asynchronous case, previous tickets blinks during swipe to dismiss. //noinspection deprecation getCursor().requery(); return new Pair<Long, Integer>(id, status); } else { return null; } }
Example #25
Source File: ConversationView.java From Zom-Android-XMPP with GNU General Public License v3.0 | 5 votes |
private void checkPosition() { int pos = mInnerCursor.getPosition(); int count = mInnerCursor.getCount(); if (-1 == pos || count == pos) { throw new CursorIndexOutOfBoundsException(pos, count); } }
Example #26
Source File: MatrixCursor.java From FireFiles with Apache License 2.0 | 5 votes |
/** * Sets the next column value in this row. * * @throws CursorIndexOutOfBoundsException if you try to add too many * values * @return this builder to support chaining */ public RowBuilder add(Object columnValue) { if (index == endIndex) { throw new CursorIndexOutOfBoundsException( "No more columns left."); } data[index++] = columnValue; return this; }
Example #27
Source File: MatrixCursor.java From FireFiles with Apache License 2.0 | 5 votes |
/** * Gets value at the given column for the current row. */ private Object get(int column) { if (column < 0 || column >= columnCount) { throw new CursorIndexOutOfBoundsException("Requested column: " + column + ", # of columns: " + columnCount); } if (mPos < 0) { throw new CursorIndexOutOfBoundsException("Before first row."); } if (mPos >= rowCount) { throw new CursorIndexOutOfBoundsException("After last row."); } return data[mPos * columnCount + column]; }
Example #28
Source File: MatrixCursor.java From FireFiles with Apache License 2.0 | 5 votes |
/** * Sets the next column value in this row. * * @throws CursorIndexOutOfBoundsException if you try to add too many * values * @return this builder to support chaining */ public RowBuilder add(Object columnValue) { if (index == endIndex) { throw new CursorIndexOutOfBoundsException( "No more columns left."); } data[index++] = columnValue; return this; }
Example #29
Source File: MatrixCursor.java From FireFiles with Apache License 2.0 | 5 votes |
/** * Gets value at the given column for the current row. */ private Object get(int column) { if (column < 0 || column >= columnCount) { throw new CursorIndexOutOfBoundsException("Requested column: " + column + ", # of columns: " + columnCount); } if (mPos < 0) { throw new CursorIndexOutOfBoundsException("Before first row."); } if (mPos >= rowCount) { throw new CursorIndexOutOfBoundsException("After last row."); } return data[mPos * columnCount + column]; }
Example #30
Source File: MatrixCursor.java From FireFiles with Apache License 2.0 | 5 votes |
/** * Sets the next column value in this row. * * @throws CursorIndexOutOfBoundsException if you try to add too many * values * @return this builder to support chaining */ public RowBuilder add(Object columnValue) { if (index == endIndex) { throw new CursorIndexOutOfBoundsException( "No more columns left."); } data[index++] = columnValue; return this; }