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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:05:41+00:00 2026-06-08T05:05:41+00:00

I want to query all rows from my sqlite database and then pass it

  • 0

I want to query all rows from my sqlite database and then pass it to a listview to display on my app.

Here is the code(I do have a student.java implemented):

StudentDAO.java:

public void add(Student student)
    {
        db = helper.getWritableDatabase();
        db.execSQL("insert into t_student (sid, name, age) values (?,?,?)", new Object[]
                { student.getId(), student.getName(), student.getAge()}
                );
    }

public Student findAll()
    {
        db = helper.getWritableDatabase();
        Cursor cursor = db.rawQuery("select sid, name, age from t_student", (String[]) new Object() 
                );

        if(cursor.moveToNext())
            return new Student(cursor.getInt(cursor.getColumnIndex("sid")), cursor.getString(cursor.getColumnIndex("name")), cursor.getShort(cursor.getColumnIndex("age")));
        return null;
    }


MultiList.java:

public class MultiList extends ListActivity {

    ListView lv;
    SimpleAdapter sd;

    StudentDAO dao = new StudentDAO(MultiList.this);

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

Student Alex = new Student();
        chan.setId(1);
        chan.setAge((short) 18);
        chan.setName("Alex ");
        dao.add(Alex );

        Student Queena = new Student();
        chan2.setId(2);
        chan2.setAge((short) 19);
        chan2.setName("Queena");
        dao.add(Queena);

        Student Tom = new Student();
        chan3.setId(3);
        chan3.setAge((short) 20);
        chan3.setName("Tom");
        dao.add(Tom);

            dao.findAll();////how to store them???

As you can see, now, after i inserted all three students object into my database, how do i read them and store them? Because my findAll() method return a student object.
Sorry this might be a easy question, please help

  • 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-08T05:05:43+00:00Added an answer on June 8, 2026 at 5:05 am

    There is two easy options, the best in my view is to use a CursorAdapter and pass a cursor with your query, in this case listView will load only showed elements and will dinamicaly load from database while you scroll.

    Or you can execute the query for your self and store objects in an array to show with a SimpleCursorAdapter.

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

Sidebar

Related Questions

I have a database from which I want to query and display only that
I want to write a query to select from a table all rows with
I have a query and a loop written that lists all the rows from
Here's what I want to accomplish: Select all rows from table posts while also
I'm using System.Data.SQLite to query a database with c#/linq . The rows I want
I have this query which returns all rows from a table: select Cost, Name,
I want to select all rows from my database where the id is equal
let's say that you want to select all rows from one table that have
I have two tables (Apple and Bid). I want to return all rows from
I'm working on a GAE app. I want to query datastore and retrieve all

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.