Cursor isClosed - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Cursor isClosed method.

This code example shows how to use the following methods:getCount, isClosed, moveToFirst
        assertThat(stringValueFromDatabase).isEqualTo(name);
    } 
 
    protected void assertEmptyDatabase() { 
        Cursor cursor = database.query("table_name", new String[]{"id", "name"}, null, null, null, null, null);
        assertThat(cursor.moveToFirst()).isFalse();
        assertThat(cursor.isClosed()).isFalse();
        assertThat(cursor.getCount()).isEqualTo(0);
    } 
 
    protected void assertNonEmptyDatabase() { 
        Cursor cursor = database.query("table_name", new String[]{"id", "name"}, null, null, null, null, null);
        assertThat(cursor.moveToFirst()).isTrue();
        assertThat(cursor.getCount()).isNotEqualTo(0);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:close, getColumnIndex, getCount, getString, isClosed
				"company_name_spellings.company_name='" + CompanyNameString + 
				"' AND company_name_spellings.companyId=companies._id",  
				"companies.logo ASC"); 
 
		if (cur!= null){
			if(cur.getCount() > 0){
				cur.moveToFirst();
				result = cur.getString(cur.getColumnIndex("logo"));
			} else { 
				result = UNKNOWN_RESULT;
			} 
 
			if(!cur.isClosed()){cur.close();}
			if(db.isOpen()){db.close();}
		} 
 
		return tryNull(result, UNKNOWN_RESULT);
	} 
 
 
7
CodeRank
This code example shows how to use the following methods:close, getInt, isClosed, moveToFirst, toString
	 *  
	 * @return blacklist 
	 */ 
	public int getEntrieCount() { 
		final Cursor cursor = this.db.rawQuery("SELECT COUNT(nr) FROM " + DATABASE_TABLE, null);
		Log.d(TAG, cursor.toString());
		int ret = 0;
		if (cursor.moveToFirst()) {
			ret = cursor.getInt(0);
		} 
		if (!cursor.isClosed()) {
			cursor.close();
		} 
		return ret;
	} 
 
	/** 
	 * Get all entries from blacklist. 
	 *  
	 * @return array of entries 
7
CodeRank
This code example shows how to use the following methods:getInt, getString, isAfterLast, isBeforeFirst, isClosed
		} 
	} 
 
	@Override 
	public Segment loadFromCursor(Cursor cursor) {
		if (cursor.isBeforeFirst() || cursor.isAfterLast() || cursor.isClosed()) {
			throw new IllegalArgumentException();
		} 
 
		SimpleDateFormat sdf = new SimpleDateFormat(LAST_UPDATE_FORMAT);
		Segment segment = new Segment();
		int index = 1; // 0 == _ID
 
		segment.setName(cursor.getString(index++));
		segment.setColorId(cursor.getInt(index++));
		try { 
			segment.setLastUpdate(sdf.parse(cursor.getString(index++)));
		} catch (ParseException e) {
			segment.setLastUpdate(null);
		} 

7
CodeRank
This code example shows how to use the following methods:getDouble, getInt, getString, isAfterLast, isBeforeFirst
	// 
	// METHODES DE TRAITEMENTS DE CURSOR 
	// 
 
	public ParkingEntity loadFromCursor(Cursor cursor) {
		if (cursor.isBeforeFirst() || cursor.isAfterLast() || cursor.isClosed()) {
			throw new IllegalArgumentException();
		} 
 
		ParkingEntity park = new ParkingEntity();
		int index = 1; // 0 == _ID
 
		park.setIdentifiant(cursor.getString(index++));
		park.setNom(cursor.getString(index++));
		park.setStatut(cursor.getInt(index++));
		park.setPriorite(cursor.getInt(index++));
		park.setDisponibles(cursor.getInt(index++));
		park.setSeuilComplet(cursor.getInt(index++));
		park.setPlacesTotales(cursor.getInt(index++));
		park.setHoraires(cursor.getString(index++));

7
CodeRank
This code example shows how to use the following methods:close, isClosed
	} 
 
	public void closeCursor() { 
		final Cursor cursor = getCursor();
		if (cursor == null) return;
		if (!cursor.isClosed()) {
			cursor.close();
		} 
	} 
 
	@Override 
	public CharSequence convertToString(final Cursor cursor) {
		if (isCursorClosed()) return null; 
		return cursor.getString(mScreenNameIdx != -1 ? mScreenNameIdx : mNameIdx);
	} 
 
	public boolean isCursorClosed() { 
		final Cursor cursor = getCursor();
		return cursor == null || cursor.isClosed();
	} 
7
CodeRank
This code example shows how to use the following methods:isClosed, requery
     * 
     * @see ContentObserver#onChange(boolean) 
     */ 
    @SuppressWarnings("deprecation") 
    protected void onContentChanged() { 
        if (mAutoRequery && mCursor != null && !mCursor.isClosed()) {
            mDataValid = mCursor.requery();
        } 
    } 
 
    private class ChangeObserver extends ContentObserver {
 
        public ChangeObserver() { 
            super(new Handler());
        } 
 
        @Override 
        public boolean deliverSelfNotifications() { 
            return true; 
        } 
7
CodeRank
This code example shows how to use the following methods:isClosed
    wrappedCursor.close();
  } 
 
  @Implementation 
  public boolean isClosed() { 
    return wrappedCursor.isClosed();
  } 
 
  @Implementation 
  public void registerContentObserver(ContentObserver contentObserver) {
    wrappedCursor.registerContentObserver(contentObserver);
  } 
 
  @Implementation 
  public void unregisterContentObserver(ContentObserver contentObserver) {
    wrappedCursor.unregisterContentObserver(contentObserver);
  } 
 
  @Implementation 
  public void registerDataSetObserver(DataSetObserver dataSetObserver) {
7
CodeRank
This code example shows how to use the following methods:getCount, isClosed
         * {@inheritDoc} 
         */ 
        @Override 
        public int getCount() { 
            // Check for errors 
            if (mCursor == null || mCursor.isClosed() || mCursor.getCount() <= 0) {
                return 0; 
            } 
            return mCursor.getCount();
        } 
 
        /** 
         * {@inheritDoc} 
         */ 
        @Override 
        public long getItemId(final int position) {
            return position;
        } 
 
        /** 
6
CodeRank
This code example shows how to use the following methods:getCount, isClosed
    public long getCombinedGroupId(long groupId) {
        return groupId;
    } 
 
    public boolean isEmpty() { 
        return mCursor.isClosed() || mCursor.getCount() == 0;
    } 
} 
6
CodeRank

Related Cursor isClosed Questions & Answers:

isClosed Method Overview
return true if the cursor is closed
See Code Examples for other Android Cursor Methods: