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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:17:36+00:00 2026-06-06T01:17:36+00:00

I am having 2 cursors from different tables in an SQLite database. I am

  • 0

I am having 2 cursors from different tables in an SQLite database. I am trying to put the data from the two cursors into one ListView but for different formatting for data from each cursor.

What I thought about is using a MergeCursor to combine both cursors, but the ViewBinder for my SimpleCursorAdapter will see them as a single cursor and will not be able to differentiate for formatting (unless I alter my tables, which I do not want to do).

Finally, I found 2 methods called Cursor.repond(Bundle) & Cursor.getExtras(), but the documentation on the developer console is very short and Googling these methods did not clarify their use.

I tested my idea to use resond() in my Database class for the query:

    extr.putString("table", the_tab);
    Cursor c_in = db.rawQuery(qry, null);
    c_in.respond(extr);
    return c_in;

And use getExtras() in the ViewBinder to know the table of the query and format the ListView item accordingly:

Bundle extr=cur.getExtras();
String tab= extr.getString("table");

But I am always getting an exception that tab is null.

My question after this long description is: Am I using the respond and getExtras methods correctly? And if not, is there a better approach for my problem?

  • 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-06-06T01:17:37+00:00Added an answer on June 6, 2026 at 1:17 am

    Try building the table name in as a field in the two SELECTs.

    SELECT "A", * from tableA;  SELECT "B", * from tableB;
    

    then compute a merged cursor. Alternately,

    SELECT "A", * from tableA UNION ALL SELECT "B", * from tableB;
    

    Now each row of the cursor will have a "A" in the first column if it came from tableA and a "B" if it came from tableB. So it’s easy to look at this column in your ViewBinder to make formatting decisions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to return two ref cursors from a procedure and having a bit
I need to merge data from 2 tables into a third (all having the
I have made the following code to retrive data from SQLite database. public Cursor
I am trying to join two tables. One being the sys.databases table and the
Having issue with displaying the Data from a second Activity. when I run the
I am trying to make my app rotation friendly, but I am having some
I'm using the Oracle data libraries in .NET to get multiple tables returned from
I'm having an alignment issue, I'm trying to position the labels from start to
I have a cursor returned from Database executes in 31ms (milliseconds) . But when
Having a list of data object and something visual to represent each, where would

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.