Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4015062
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:34:23+00:00 2026-05-20T09:34:23+00:00

I have a database as follows: —————————— BOOK NAME | BOOK FORMAT | COUNT

  • 0

I have a database as follows:

------------------------------
BOOK NAME | BOOK FORMAT | COUNT |
------------------------------
Android   | HTML       | 1
WPF       | PDF        | 10
Symbian   | PS         | 2
Windows   | HTML       | 2

I am showing this database to the user
by making use of a CustomSimpleCursorAdapter.

CustomSimpleCursorAdapter extends SimpleCursorAdapter

implements Filterable

with getView() & runQueryonBackgroundThread() being overriden.
The Grid view of books is properly shown.

The user has the following options:

HTML | PDF | PS | DELETE

Constraint: BOOK FORMAT
[HTML - 1, PDF - 2, PS - 3] 

When the user presses HTML menu option, the books with HTML
type has to be shown.

inside MenuOption handler(), I wrote as follows:

adapter.getFilter().filter("1");

runQueryonBackgroundThread() {
    if(mCursor != null)
        mCursor.close();
    mCursor = query(using the constraint)
    return mCursor;
}

This constraint reaching my overriden runQueryonBackgroundThread()
method. But its not updating the grid view and throws an exception.

“FILTER: android.view.ViewRoot$CalledFromWrongThreadException: Only the
original thread that created a view hierarchy can touch its views”

Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:34:23+00:00Added an answer on May 20, 2026 at 9:34 am

    I think you’ve messed up things a bit. Actually SimpleCursorAdapter already implements Filterable, so there’s no need to reimplement it. Instead in your ListActivity use smth like this:

    private void filterList(CharSequence constraint) {
        final YourListCursorAdapter adapter = 
            (YourListCursorAdapter) getListAdapter();
        final Cursor oldCursor = adapter.getCursor();
        adapter.setFilterQueryProvider(filterQueryProvider);
        adapter.getFilter().filter(constraint, new FilterListener() {
            public void onFilterComplete(int count) {
                // assuming your activity manages the Cursor 
                // (which is a recommended way)
                stopManagingCursor(oldCursor);
                final Cursor newCursor = adapter.getCursor();
                startManagingCursor(newCursor);
                // safely close the oldCursor
                if (oldCursor != null && !oldCursor.isClosed()) {
                    oldCursor.close();
                }
            }
        });
    }
    
    private FilterQueryProvider filterQueryProvider = new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            // assuming you have your custom DBHelper instance 
            // ready to execute the DB request
            return dbHelper.getListCursor(constraint);
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 tables in my SQL database as follows Users2 UserID, EID, Name,
I have database table whose structure is as follows: id int name varchar(20) dob
Currently have a database formatted as follows: id (unique id) url: http://domain.com/page.html Urls are
I have a database table as follows. <table border='1'><th>Id</th><th>FirstName</th><th>last Name</th><tr><td>1</td><td>Tom</td><td>T</td></tr><tr><td>2</td><td>Jerry</td><td>J</td></tr></table> I would like to
I have database relation as follows between question table and Hardware detail table .
I have SQL database as follows alt text http://img97.imageshack.us/img97/5774/dbimage.jpg Now I want to filter
We have a method which initialises a test database as follows: $db=file_get_contents('test-data.sql'); /* @var
I have a database as follows: --------------------------------------------------------------- | module_name | category | content |
Let's assume that I have a table in a mysql database as follows, date
I have a database with four tables as follows: Addressbook -------------------- id more fields

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.