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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:42:16+00:00 2026-05-26T07:42:16+00:00

I insert data using the follow command and getting true as a result of

  • 0

I insert data using the follow command and getting true as a result of insert command ..

 public boolean insertAppointment(Appointment appointment) {
        SQLiteDatabase db=this.getReadableDatabase();
        ContentValues values = new ContentValues();
        values.put(COL_EVENT_ID, appointment.mEventId);
        values.put(COL_START_DATE, formatter.format(appointment.mStartDate));

    //  Log.d("date when insert",appointment.mStartDate+"");

        values.put(COL_END_DATE, formatter.format(appointment.mEndDate));

        values.put(COL_EVENT_BODY, appointment.mBody);        
        values.put(COL_EVENT_TITLE, appointment.mTitle);
        values.put(COL_STUDENT_ID, appointment.mStudentId);        
        values.put(COL_EVENT_STATUS, appointment.mSatus);
        values.put(COL_SERVICE_NUMBER, appointment.mServiceNo);        
        values.put(COL_PASSWORD, appointment.mPassword);
        values.put(COL_LECTURER_ID, appointment.mLecturerId);        
        values.put(COL_SEC_NO, (Integer)appointment.mSecNo);
        values.put(COL_DEPT_NO, (Integer)appointment.mDeptNo);
        values.put(COL_FLOOR_NO, (Integer)appointment.mFloorNo);
        boolean r = db.insert(TIMETABLE_TABLE, null, values) > 0 ;

        Log.d("db:appointments rows inserted",r+"");
        Log.d("db:appointments rows after insert",this.getAllAppointments().size()+"");

        db.close();
        return r;
    }

But when trying to retrieve data using the following command,
I don’t get any result !? Why ?

edit

Here is the the function that is responsible for retrieving data

public ArrayList<Appointment> getAllAppointments(){
    ArrayList<Appointment> appointments = new ArrayList<Appointment>();
    Appointment appointment = null;
    SQLiteDatabase db = this.getWritableDatabase();

    String query = "SELECT "+
            COL_EVENT_ID+ " as _id,"+
            COL_START_DATE+", "+
            COL_END_DATE+", "+
            COL_EVENT_BODY+", "+
            COL_EVENT_TITLE+", "+
            COL_STUDENT_ID+", "+    
            COL_EVENT_STATUS+", "+
            COL_SERVICE_NUMBER+", "+
            COL_PASSWORD+", "+
            COL_LECTURER_ID+", "+       
            COL_SEC_NO+", "+
            COL_DEPT_NO+","+
            COL_FLOOR_NO+" from "+TIMETABLE_TABLE;
    Log.d("select query",query);
    Cursor c = db.rawQuery(query,new String[]{});
    Log.d("cursor",c.getCount()+"");

    c.moveToFirst();
    while(c.moveToNext()){
        appointment = new Appointment();
        try {
            appointment.mEventId = c.getInt(c.getColumnIndex("_id"));

            Date startDate = formatter.parse(formatter.format(formatter.parse(c.getString(c.getColumnIndex(COL_START_DATE)))));
            appointment.mStartDate = startDate;

            Date endtDate = formatter.parse(formatter.format(formatter.parse(c.getString(c.getColumnIndex(COL_END_DATE)))));
            appointment.mEndDate = endtDate; 

            appointment.mBody = c.getString(c.getColumnIndex(COL_EVENT_BODY));
            appointment.mTitle = c.getString(c.getColumnIndex(COL_EVENT_TITLE));
            appointment.mStudentId = c.getString(c.getColumnIndex(COL_STUDENT_ID));
            appointment.mSatus = c.getInt(c.getColumnIndex(COL_EVENT_STATUS));
            appointment.mServiceNo = c.getInt(c.getColumnIndex(COL_SERVICE_NUMBER));
            appointment.mPassword = c.getString(c.getColumnIndex(COL_PASSWORD));
            appointment.mLecturerId = c.getInt(c.getColumnIndex(COL_LECTURER_ID));
            appointment.mSecNo = c.getInt(c.getColumnIndex(COL_SEC_NO));
            appointment.mDeptNo = c.getInt(c.getColumnIndex(COL_DEPT_NO));
            appointment.mFloorNo = c.getInt(c.getColumnIndex(COL_FLOOR_NO));
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        appointments.add(appointment);
    }
    db.close();
    return appointments;
}
  • 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-26T07:42:16+00:00Added an answer on May 26, 2026 at 7:42 am

    try this,,,

    use SQLiteDatabase db = this.getWritableDatabase(); when inserting the values.

    use SQLiteDatabase db=this.getReadableDatabase(); when reading the values.

    you are using them in reverse.

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

Sidebar

Related Questions

I need to insert/update data by using link or image I need a code
How i insert data into xml file using Windows Application in .net?
How do you insert data into a MySQL date or time column using PHP
I am using LINQ to SQL to insert simple data into a table WITHOUT
I'm using INSERT INTO to copy rows of data from one table to another:
I am using following query to insert some large text data : internal static
My jQuery code (using ajax) request's data from a local php script (pgiproxy.php). This
In PHP, I want to insert into a database using data contained in a
I want to insert data using XML in SQL Server 2005. So I got
I have a process that imports a lot of data (950k rows) using inserts

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.