The following code is supposed to test whether the SelfCursor is empty or
not and to do different things depending on that result:

 

private void register() {

      registered = false;

        db = new ChessDataBaseAdapter(this);

        db.open();

        Cursor c = db.getSelfCursor();

        Log.d(TAG, "closing database");

        db.close();

        

        if (c.moveToFirst()) {

            // TODO

            c.close();

        }

        else {    // Player has not yet registered

            Log.d(TAG, "closing self cursor");

            c.close();

            startRegistrationActivity();              

        }

    }

 

moveToFirst() is supposed to return false if the cursor is empty, and that's
what I'm wanting here. But, when my cursor is empty, it's also causing a
bothersome error to show up in LogCat:

 

Cursor      invalid statement in fillWindow()

 

The program doesn't crash, but I still don't like seeing the error. I gather
that fillWindow() (in AbstractCursor) is supposed to copy data from the
cursor to the CursorWindow, which is no doubt a problem if there's nothing
in the cursor.

 

Is there a good way to test whether my cursor is empty without getting this
error-i.e., without calling fillWindow()? I first tried c.getCount() > 0 but
got the same error. Any other ideas?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to