Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 653
irobotxx Avatar asked Nov 16 '10 14:11

irobotxx


People also ask

How does cursor work in Android?

Cursors are what contain the result set of a query made against a database in Android. The Cursor class has an API that allows an app to read (in a type-safe manner) the columns that were returned from the query as well as iterate over the rows of the result set.

What is the use of cursor in Android explain with example?

This interface provides random read-write access to the result set returned by a database query. Cursor implementations are not required to be synchronized so code using a Cursor from multiple threads should perform its own synchronization when using the Cursor.


1 Answers

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.myDatabaseClassObj != null) {         this.myDatabaseClassObj.close();       }     } catch (Exception error) {       /** Error Handler Code **/     }// end try/catch (Exception error)   }// end onStop 
like image 188
3 revs Avatar answered Sep 28 '22 14:09

3 revs