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 971097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:54:30+00:00 2026-05-16T02:54:30+00:00

I am having some trouble in using a rawQuery to get a cursor for

  • 0

I am having some trouble in using a rawQuery to get a cursor for use in an ExpandableListView. I have an adapter class called ExpandableDataAdapter which extends SimpleCursorTreeAdapter. Here is the line I have to create an instance of the ExpandableDataAdapter:

ExpandableDataAdapter confDataAdapter = new ExpandableDataAdapter(
       this,
       groupCursor,
       R.layout.detaillist_group,
       new String[]{ "TrackName" },
       new int[]{ R.id.rowText },
       R.layout.detaillist_child,
       new String[]{ "Title", "Speakers", "TrackName", "Room" },
       new int[]{ R.id.sessionTitle, R.id.sessionSpeakers, R.id.sessionTrack, R.id.sessionRoom }
      );

Inside the ExpandableDataAdapter class definition, I have the following method to get the children cursor for a group cursor:

protected Cursor getChildrenCursor(Cursor groupCursor) 
{
     // Given a group, return a cursor for all the children in that group.
     Cursor talksCursor = _db.rawQuery("SELECT t1.TalkID as _id, t1.Title," +
     " 'None' as Speakers, t2.TrackName, t1.Room" +
     " from talks t1, tracks t2" +
     " where t1.TrackID = t2.TrackID" +
     " and t2.TrackID=?", new String[]{ groupCursor.getString(groupCursor.getColumnIndex("_id")) });   
   startManagingCursor(talksCursor);
   return talksCursor;
}

The above query works, and the ExpandableListView shows up. But, of course, the above is a simpler version of the actual query which I want to execute. When I replace it with the actual (and somewhat more complicated) query, I get an exception. First, the query:

protected Cursor getChildrenCursor(Cursor groupCursor) 
{
   // Given a group, return a cursor for all the children in that group.
   Cursor talksCursor = _db.rawQuery("SELECT t1.TalkID as _id, t1.Title," +
     " group_concat(t3.Speaker, ', ') as Speakers, t2.TrackName, t1.Room" +
     " from talks t1, tracks t2, talkspeaker t3" +
     " where t1.TalkID = t3.TalkID" +
     " and t1.TrackID = t2.TrackID" +
     " and t2.TrackID=?" +
     " group by _id, t1.Title, t2.TrackName, t1.Room", 
      new String[]{ groupCursor.getString(groupCursor.getColumnIndex("_id")) });
   startManagingCursor(talksCursor);
   return talksCursor;
}

The exception I get is: column ‘Room’ does not exist. This latest query works fine from a database prompt, so I am guessing that something is happening when being executed by android engine. Also, the exception statement has me stumped as well. Am I using too many tables? Is the group_concat function creating trouble?
Any pointers?

More notes: the exception is thrown from the constructor of the adapter, which is defined as follows. I am calling the constructor as shown in the first snippet in this post.

public ExpandableDataAdapter(Context context, Cursor cursor,
      int groupLayout, String[] groupFrom, int[] groupTo,
      int childLayout, String[] childFrom, int[] childTo) 
 {
       super(context, cursor, groupLayout, groupFrom, groupTo, 
                             childLayout, childFrom, childTo);
 }
  • 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-16T02:54:30+00:00Added an answer on May 16, 2026 at 2:54 am

    Figured it out – looks like I had to explicitly declare the column names in the second query. Frankly, I am not sure if this was indeed the problem or if this is the correct solution, but at list, the ExpandableListView is showing up. The working snippet is:

    Cursor talksCursor = _db.rawQuery("SELECT t1.TalkID as _id, t1.Title as Title," +
            " group_concat(t3.Speaker, ', ') as Speakers, t2.TrackName as TrackName, t1.Room as Room" +
        " from talks t1, tracks t2, talkspeaker t3" +
        " where t1.TalkID = t3.TalkID" +
        " and t1.TrackID = t2.TrackID" +
        " and t2.TrackID=?" +
        " group by _id, t1.Title, t2.TrackName, t1.Room", 
            new String[]{ groupCursor.getString(groupCursor.getColumnIndex("_id")) });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 486k
  • Answers 486k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For this answer I'm assuming that you're willing to do… May 16, 2026 at 8:05 am
  • Editorial Team
    Editorial Team added an answer If I understand what you mean In XML : android:id="your_id"… May 16, 2026 at 8:05 am
  • Editorial Team
    Editorial Team added an answer i use this, it's ok. intent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i think… May 16, 2026 at 8:05 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.