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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:50:44+00:00 2026-06-04T12:50:44+00:00

I dont have much knowledge in using the Cursor to read data of SQLite

  • 0

I dont have much knowledge in using the “Cursor” to read data of SQLite database but using some references and examples i compiled a few to setup this i dont why it would read from the database, i check if data is entered into the database using a database browser and its present can some one tell me how to make this work?

I have a separate class holding the db connections and queries, in that i have a function to get all fields which have a long value of a specifed value

public Cursor getAppointments(long date) throws SQLException
    {
    Cursor mCursor =
    db.query(true, DATABASE_TABLE, new String[] {
    KEY_ROWID,
    APP_TIME,
    APP_TITLE,
    },
    APP_DATE + "="  + date,
    null,
    null,
    null,
    null,
    null);
    if (mCursor != null) {
    mCursor.moveToFirst();
        }
    return mCursor;
    }

what this code is supposed to do is get all the records which have the corresponding date as the queried value and return.

Now in the main class i have this code to catch and display in a Textview, row by row.

 db.open();
       Display.setText("");
       Cursor c = db.getAppointments(SDate);

      if (c.moveToFirst())
          Display.setText(DisplayTitle(c));
       else
       Toast.makeText(this, "No title found",
       Toast.LENGTH_LONG).show();

       db.close();

and the display title method is

private String DisplayTitle(Cursor c) {

        String Final ="";

        Final = c.getString(1)  + " " +c.getString(2) + " " +  c.getString(3)  + "\n" ;

        return Final;

    }

Can someone tell me what are the changes necessary inorder to retrieve the records which have the same long value as the date and display it in the textview, there can be multiple records with the same long value, so have to retrieve all the records with the same long value for date and display it in the textview.

Cheers, Looing for a fast reply. 🙂

  • 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-04T12:50:45+00:00Added an answer on June 4, 2026 at 12:50 pm

    Use this simple approach of using cursor:

     String q = "SELECT * FROM DATABASE_TABLE where(APP_DATE like '"+date+"')";//your query
     Cursor c = db.rawQuery(q, null); //  db is a object of SQLiteDatabase type  
    

    Then retrieve value of respective column using column name with getColumnIndex() method if you are not sure about column index like:

                  if(c.getCount() == 0)
                  {                   
                     //No entry found
                  }
                  else  {
                      c.moveToFirst();
                      do {
                          String mail = c.getString(c.getColumnIndex("KEY_ROWID"))+c.getString(c.getColumnIndex("APP_TIME"))+c.getString(c.getColumnIndex("APP_TITLE")); 
                            // do whatever you like with each record                    
                        } while (c.moveToNext());               
                c.close();
                db.close();
    

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

Sidebar

Related Questions

I dont know much about classes, but have a reasonable knowledge of PHP/MySQL. But
This might be a simple one, but since I don't have much knowledge about
What does x :: xs' mean? I dont have much functional experience but IIRC
Not much knowledge about Javcascript beyond using it for some Dynamic HTML. Now I'm
I don't have much experience working with resultsets, but as ResultSet is an interface,
I don't have much experience with Serial I/O, but have recently been tasked with
i need horizontal scrolling script in javascript, but don't have much time to write
I'm talking to a DDE server I don't have very much documentation for using
i dont have microsoft access but would like to open an mdb file, is
I'm trying to write a game engine in Android, but I don't have much

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.