Aller au contenu | Aller au menu | Aller à la recherche


android.database.Cursor moveToFirst or getCount

moveToFirst vs getCount ? Wich is faster on android.database.Cursor ?

It's almost the same time because Cursor.moveToFirst() call SQLiteCursor.getCount().

Look at

// android.database.AbstractCursor

    /* These need to be implemented by subclasses */
   abstract public int More ...getCount();

    public final boolean moveToFirst() {
        return moveToPosition(0);
    }

    public final boolean moveToPosition(int position) {
        // Make sure position isn't past the end of the cursor
        final int count = getCount();
        // ....    
    }

// android.database.sqlite.SQLiteCursor

    @Override
    public int More ...getCount() {
        if (mCount == NO_COUNT) {
            fillWindow(0);
        }
        return mCount;
    }

Ajouter un commentaire

Le code HTML est affiché comme du texte et les adresses web sont automatiquement transformées.

Fil des commentaires de ce billet