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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:25:04+00:00 2026-05-27T12:25:04+00:00

In the code below, I’m getting only the last row in my database, i.e.

  • 0

In the code below, I’m getting only the last row in my database, i.e. first name and last name of the last row in my DB. My question is: how do I change this code in order to get all the results printed?

package samples.directory;      

import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class clanguage extends Activity {
protected Cursor c;
protected SQLiteDatabase db;


protected TextView employeeName;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webdesign);
    WebView engine = (WebView) findViewById(R.id.web_engine);

    db = (new DatabaseHelper(this)).getWritableDatabase();

    Cursor c = db.rawQuery("SELECT firstName, lastName FROM employee", null);
    if (c != null ) {
        if  (c.moveToFirst()) {
            do {
                String firstName= c.getString(c.getColumnIndex("firstName"));
                String lastName = c.getString(c.getColumnIndex("lastName "));                                                   
                String data = "<html>" +
                    "<body><table border=2> <tr> <td>"+firstName+"</td>+                                
                    <td>"+lastName+"</td></tr></body></html>";

                engine.loadData(data, "text/html", "UTF-8");

            }while (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-05-27T12:25:04+00:00Added an answer on May 27, 2026 at 12:25 pm

    try this way

    StringBuffer data = new StringBuffer("<html>");
    data.append("<body><table border=2>");
    do {
    
        String firstName= c.getString(c.getColumnIndex("firstName"));
        String lastName = c.getString(c.getColumnIndex("lastName "));
    
        data.append("<tr> <td>"+firstName+"</td><td>"+lastName+"</td></tr>");
    
    }while (c.moveToNext());
    data.append("</table></body></html>");
    engine.loadData(data, "text/html", "UTF-8");
    

    you everytime override content of data object and load it.

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

Sidebar

Related Questions

(code below regarding my question) Per this stack overflow question I used Pegolon's approach
The code below seems to only return the first two digits of my IP
The code below get image from some location - and make this image compress
The code below gives me this mysterious error, and i cannot fathom it. I
Code below sets default values for new row if row is added using form.
code below. i'm tryind to obtain string answers like a1, c4 this is what
In below code i'm doing somthing wrong. Sorry if this is a bit basic.
This code below causes infinate loop problem (as documented). So how do I set
The code below works great. It prints out items in a MySQL database as
See code below, for some reason it only works when I put a breakpoint

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.