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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:59:46+00:00 2026-05-27T20:59:46+00:00

I have written some thing like this to fetch data from the database. public

  • 0

I have written some thing like this to fetch data from the database.

public String getData() {
    // TODO Auto-generated method stub
    String[] columns = new String[]{ KEY_ROWID, KEY_NAME, KEY_SCORE};
    Cursor c = ourDatabase.query(
                DATABASE_TABLE, columns, null, null, null, null, null);
    String result = "";

    int iRow = c.getColumnIndex(KEY_ROWID);
    int iName = c.getColumnIndex(KEY_NAME);
    int iHotness = c.getColumnIndex(KEY_SCORE);

    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
        result = result + c.getString(iRow) + " " + c.getString(iName) + " " + c.getString(iHotness) + "\n";
    }

    return result;
}

and i am able to show data into textview. But i want to show data into listview can anyone suggest me or give me a sample code to show data into listview. I had taken a list.xml and put a listview in that. I want to fetch data from the database.

thanks in advance.

  • 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-27T20:59:47+00:00Added an answer on May 27, 2026 at 8:59 pm
    public String[] getData() {
        // TODO Auto-generated method stub
        String[] columns = new String[]{ KEY_ROWID, KEY_NAME, KEY_SCORE};
        Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
        //Initialise the result variable
        String[] result = new String[c.getCount()];
    
        int iRow = c.getColumnIndex(KEY_ROWID);
        int iName = c.getColumnIndex(KEY_NAME);
        int iHotness = c.getColumnIndex(KEY_SCORE);
        int counter = 0;
        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
            result[counter] = c.getString(iRow) + " " + c.getString(iName) + " " + c.getString(iHotness) + "\n";
            counter++;
        }
    
        return result;
    }
    

    Then in the ListView onCreate you add the result string to you adapter.

       setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, result));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written something like this pretty easily in C# ( string GetUrl(new {
I have an application written in Python. It collects and parses data from certain
I'm still confused... When we write some thing like this: Object o = new
I have written something like this in PHP <script type=text/javascript src=jquery.js></script></script> <script type=text/javascript> function
I have written an exporter that exports strings to .csv Thing is, some of
I am trying to create a match for this pattern: /page/some/thing/is/written/here where /page is
This should be a very simple thing to have run, but for some reason
I have written some code in my VB.NET application to send an HTML e-mail
I have written some CSS which targets elements using the parent > child selector.
I have written some code for playing a .wav through my application. Now I

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.