Skip to main content

what does Invalid statement in fillWindow() in android cursor mean?



i sometimes see this error in my logcat output, Cursor: invalid statement in fillWindow(). it sometimes happens when i press the back key and then it goes to the default android listview before going to my custom listview.





what does it mean? how do i solve it? Because it does not point to any line of code where the problem is coming from?



Source: Tips4all

Comments

  1. When dealing with ListActivities, this issue has to do with the Cursor objects, CursorAdapter objects, and Database objects not being closed properly when the Activity stops, and not being set properly when the Activity starts or resumes.

    I had to make sure that I closed my SimpleListAdapter, my Cursors, and then my Database objects in that respective order, in the onStop method of the Activity that is called when the TabActivity resumes.

    I had already been closing the Cursor and Database objects, but had not been closing my SimpleListAdapter Cursor.

    /**
    * onStop method
    *
    * Perform actions when the Activity is hidden from view
    *
    * @return void
    *
    */
    @Override
    protected void onStop() {
    try {
    super.onStop();

    if (this.mySimpleListAdapterObj !=null){
    this.mySimpleListAdapterObj.getCursor().close();
    this.mySimpleListAdapterObj= null;
    }

    if (this.mActivityListCursorObj != null) {
    this.mActivityListCursorObj.close();
    }

    if (this.dbActListObj != null) {
    this.dbActListObj .close();
    }
    } catch (Exception error) {
    /** Error Handler Code **/
    }// end try/catch (Exception error)
    }// end onStop

    ReplyDelete
  2. It is of utmost importance that you close the Cursors, Databases, DBHelpers in the right order.

    for e.g.
    for the given code below.

    DBHelper dbhelper = new DBHelper();
    SQLiteDataBase db = dbhelper.getWritableDatabase();

    Cursor c = db.query(/*some parameters*/);


    the order of closing should be like:

    c.close();
    db.close();
    dbhelper.close();


    Otherwise different errors keeps on spawning and the developer does not even come to know about it.

    ReplyDelete
  3. If you are using a custom Class instance e.g. Model m that holds a DatabaseManager, which in turn holds a SQLiteDatabase: Model->DatabaseManager->SQLiteDatabase

    Then, if you do a query to m (which does the appropiate delegations) and then you do something like m.close() (which actually closes the SQLiteDatabase) and after that you try to use the Cursor you will get that error.

    The solution is: first use the cursor and then close the Db.

    My response is based in the 2 existing so far, that inspired me to solve the problem.

    ReplyDelete
  4. Maybe this can help you: http://www.ragtag.info/2011/feb/1/database-pitfalls/

    It seems that calls to getReadableDatabase and getWritableDatabase returns the same connection to the database (even if you made several calls to them).
    So, any call to close() on any of them will close both connection(s).

    If you tries to use a cursor later, you'll get the nice 'Invalid statement', since the connection which the cursor relies on, is already closed.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.