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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:35:51+00:00 2026-06-08T15:35:51+00:00

So here it goes, i have this application retrieves records from database, i have

  • 0

So here it goes, i have this application retrieves records from database, i have 5 entries from my database, and retrieved its using this code;

Cursor c = dbconnection.rawQuery("SELECT * from Patients", null);

after that i looped it to retrieve the data pero row in my Database as such;

c.moveToFirst();
while(!c.isAfterLast())
{
 //Some code to put records per column in to a Patient Object 
 c.moveToNext();
}

So my problem is that as it enters the loop my Emulator freezes and as i tried to display per record into a Log, i won’t cuz the emulator it self already frozed.

Can somebody enlighten me into this matter, This issue is really really new to me

EDIT

yes already tried what baya and ofir suggested.. they worked out but i have this null error during iteration with this loop code

Cursor c = dbHelper.retrieveAllData();

                c.moveToFirst();

                while(c.moveToNext())
                {
                    Log.d("dbcheck",Integer.toString(c.getPosition()));
                    //Log.d("dbcheck",c.getString(c.getColumnIndex("firstname")));
                    //Log.d("dbcheck",c.getString(c.getColumnIndex("lastname")));
                    **p.setFname(c.getString(c.getColumnIndex("firstname")));**
                    p.setMi(c.getString(c.getColumnIndex("middleinitial")));
                    p.setLname(c.getString(c.getColumnIndex("lastname")));
                    p.setAddr(c.getString(c.getColumnIndex("address")));
                    p.setAge(c.getInt(c.getColumnIndex("age")));
                    p.setMed_history(c.getString(c.getColumnIndex("med_history")));
                    p.setPat_status(c.getString(c.getColumnIndex("status")));
                    patientList.add(p);

                }

i have a null exception error on the p.setFname() line.. i don’t know how it became null where in fact i already displayed it with Log using that code that is commented out..

  • 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-08T15:35:53+00:00Added an answer on June 8, 2026 at 3:35 pm

    Just try,

             Cursor c = dbconnection.rawQuery("SELECT * from Patients", null);
        if (c.getCount() > 0) {
    
            Patient p;
    
            while(c.moveToNext) {
    
                //initialize ur object to store new patient info.
                p = new Patient();
                p.setFname(c.getString(c.getColumnIndex("firstname")));
    
                //add newly created patient to ur list
                patientList.add(p);
    
            }
        }
    c.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this entities: public class Parent: AllDependant { /*Properties goes here*/ } public
This is a very basic question...quite embarassing, but here goes: I have a Stopwatch
I'm guessing this isn't possible, but here goes. I have two tables, and I'm
This is probably a silly question, but here it goes.Imagine you have the following
OK. This might be more of a math question but here goes. I have
This may sound like a very generic question but here it goes. I have
I have several divs like this <div rel=5> Divs content goes here </div> <div
I know this might be a long shot, but here it goes. I have
i have a small problem here which i cannot fix,This post goes through but
Here goes: I have an application that does some processing, writes some result files

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.