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

  • Home
  • SEARCH
  • 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 6780303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:29:24+00:00 2026-05-26T16:29:24+00:00

I have made the following code to retrive data from SQLite database. public Cursor

  • 0

I have made the following code to retrive data from SQLite database.

public Cursor fetchAllScores() {
    return database.query(DATABASE_TABLE, new String[] { KEY_ROWID,
            KEY_PLAYDATE, KEY_NUMVALA, KEY_NUMVALB }, null, null, null,
            null, null);
}

Then I call this function in my main.java file using the following

cursor = dbHelper.fetchAllScores();
    startManagingCursor(cursor);

After having cursor I manage to populate myGridView with some data using following code

GridView myGV = (GridView)findViewById(R.id.gridView1);

    String[] cols = new String[] { scoreDbAdapter.KEY_PLAYDATE, scoreDbAdapter.KEY_NUMVALA, scoreDbAdapter.KEY_NUMVALB};
    int[]   views = new int[] { android.R.id.text1, android.R.id.text2, android.R.id.text2 };

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, 
            android.R.layout.simple_list_item_1, cursor, cols, views);

    Log.w("NumRows",adapter.getCount() + "");

    myGV.setAdapter(adapter);

Now the problem is only first row is populated and first two columns, I want data like in forst row (2011-10-27 , 5 , 6 ) and second row like (2011-10-26 , 3 , 2 ) but i m getting is only forst row like (2011-10-27, 2011-10-26 ).

Can this be fixed in GridView?

  • 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-26T16:29:25+00:00Added an answer on May 26, 2026 at 4:29 pm

    Make a new layout which contains textViews. Find the layout as shown in first line of the code below and attach your data to the listView. ListView loads the layout containing textView.

    private void populateGrid()
    {
    
        ListView lv = (ListView)findViewById(R.id.listView1);
    
        Cursor c = dbHelper.fetchAllScores();
        startManagingCursor(cursor);
    
        String[] cols = new String[] { TodoDbAdapter.KEY_PLAYDATE, TodoDbAdapter.KEY_NUMVALA, TodoDbAdapter.KEY_NUMVALB};
        int[]   views = new int[] { R.id.txt_date, R.id.txt_no, R.id.txt_yes};
    
        // Now create an array adapter and set it to display using our row
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, 
                R.layout.listviewtemp, c, cols, views);
    
        Log.w("NumRows",adapter.getCount() + "");
    
        lv.setAdapter(adapter);
    
    }
    

    R.layout.listviewtemp is the listView template layout (separate xml), lv is the listview found in the mainlayout.xml.

    public Cursor fetchAllScores() {
        return database.query(DATABASE_TABLE, new String[] { KEY_ROWID,
                KEY_PLAYDATE, KEY_NUMVALA, KEY_NUMVALB }, null, null, null,
                null, null);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made the following code:- class A{ bool bFlag[2]; public: A(){ for(int i
I have the following code: EntityQuery<Web.Ticket> query = from t in ticketClass.getQuery() where t.showId
I have roughly the following code. Could this be made nicer or more efficient?
I have an application that is made up of the following: A central database
I was using the following code to retrieve HTML snippets from a database table
I have the following code: Dim dbHousing As New dcHousingDataContext Dim pullresidents = From
I am trying to understand pthreads by example. I have made the following code
How to update table data with data stored in session? I have following code
I have made following code, but whatever I type it will always print some
I have made something like the following code: protected void Page_Load(object sender, EventArgs e)

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.