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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:16:19+00:00 2026-06-12T09:16:19+00:00

I am trying to query all the columns in a table into one long

  • 0

I am trying to query all the columns in a table into one long text view and/or string. I know this might not be the right way to do things but I have to do this. Correct me if I am wrong, I was under the impression that move next would get the next column in the row:

Cursor c = db.get();
if(c.moveToFirst){
  do{
    string = c.getString(0);
  }while(c.moveToNext);
}

I thought that this would get the first column and display all of its contents instead I get the first column and first row. What am I doing wrong? Is there a better or real way to get this information without using a ListView?

  • 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-12T09:16:20+00:00Added an answer on June 12, 2026 at 9:16 am

    For clarity a complete example would be as follows which I trust is of interest. As code comments indicated we essentially iterate over database rows and then columns to form a table of data as per database.

        Cursor cursor = getActivity().getContentResolver().query(uri, projection, null, null,
                null);
    
        //if the cursor isnt null we will essentially iterate over rows and then columns
        //to form a table of data as per database.
        if (cursor != null) {
    
            //more to the first row
            cursor.moveToFirst();
    
            //iterate over rows
            for (int i = 0; i < cursor.getCount(); i++) {
    
                //iterate over the columns
                for(int j = 0; j < cursor.getColumnNames().length; j++){ 
    
                    //append the column value to the string builder and delimit by a pipe symbol
                    stringBuilder.append(cursor.getString(j) + "|"); 
                }
                //add a new line carriage return
                stringBuilder.append("\n");
    
                //move to the next row
                cursor.moveToNext();
            }
            //close the cursor
            cursor.close();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to query a table, fetch all records, and save the result as
I'm trying to build a query to grab all rows from Table 1, then
I am trying to generate a query that selects all from a user table
The following query works properly to pull company names from one table into jquery
I am trying to search one table for all values in rows with the
I am trying to use the Netflix OData API. I wanted to query all
I'm trying a query in Grails 1.2.1, find all products by tenant type. My
I am trying to achieve an LDAP query to gather all properties we have
I am trying to write an SQL query to retrieve all of a users
I am trying to write a simple correlated sub query that deletes all records

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.