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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:18:16+00:00 2026-06-17T03:18:16+00:00

Please check what problem with this .I am trying to retrive all records in

  • 0

Please check what problem with this .I am trying to retrive all records in my table (contains 11 records with 3 columns "name","address","city") but my code showing only one i.e last inserted record on my screen. but i need to display all records.

public void readData(View v)
    {
        DatabaseClass mydb = new DatabaseClass(this);
        SQLiteDatabase readdata = mydb.getReadableDatabase();
        TextView tv = (TextView)findViewById(R.id.readtext);
        Cursor c = readdata.rawQuery("select * from mylistdata", null);
        int[] elementId = {R.id.textView1, R.id.textView2, R.id.textView3}; 
        if(c !=null)
        {
            c.moveToFirst();
            while(c.isAfterLast() == false)
            {
                listData = new ArrayList<GenericListItem>();
                String name = c.getString(c.getColumnIndex(DatabaseClass.NAME));
                String address = c.getString(c.getColumnIndex(DatabaseClass.ADDRESS));
                String city = c.getString(c.getColumnIndex(DatabaseClass.CITY));
                listData.add(new GenericListItem(new String[]{name,address,city}));
                listAdapter = new GenericListAdapter(getApplicationContext(), R.layout.list_layout, listData, elementId);
                result.setAdapter(listAdapter);
                c.moveToNext();
            }



        }
  • 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-17T03:18:18+00:00Added an answer on June 17, 2026 at 3:18 am

    Initialize listData ArrayList outside from While loop as:

        c.moveToFirst();
        listData = new ArrayList<GenericListItem>();
        while(c.isAfterLast() == false)
        {
           // add value here to listData
          c.moveToNext();
        }
       // set  listData datasource to GenericListAdapter here
    
       listAdapter = new GenericListAdapter(getApplicationContext(), 
                  R.layout.list_layout, listData, elementId);
    
       result.setAdapter(listAdapter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a weird problem here. Please check the code below. I do not
Please check this code out it compiles and runs absolutely fine.. The question is
Please check my HTML below: <table cellpadding=0 cellpadding=0 border=0> <tr> <td> <div class=toogler>Demo1</div> </td>
PLEASE CHECK ANSWERS by VolkerK too, he provided another solution, but I can't mark
I have been trying different solutions for this problem without success. Problem is this:
All this weekend I have been trying to setup a Rails 3.0.4 app in
Please check this almost identical question first: jQuery Sortable List - scroll bar jumps
I have this database and I Need to check whether a Product Name is
I am trying to create a menu(no dropdown) using jquery. Please check some of
I'm trying to figure out the problem in this short paragraph of code. Any

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.