Note that there are some explanatory texts on larger screens.

plurals
  1. POselect command doesn't retrieve data from SQLite despite it is inserted?
    primarykey
    data
    text
    <p>I insert data using the follow command and getting <code>true</code> as a result of insert command ..</p> <pre><code> 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) &gt; 0 ; Log.d("db:appointments rows inserted",r+""); Log.d("db:appointments rows after insert",this.getAllAppointments().size()+""); db.close(); return r; } </code></pre> <p>But when trying to retrieve data using the following command, I don't get any result !? Why ?</p> <h2> edit</h2> <p>Here is the the function that is responsible for retrieving data </p> <pre><code>public ArrayList&lt;Appointment&gt; getAllAppointments(){ ArrayList&lt;Appointment&gt; appointments = new ArrayList&lt;Appointment&gt;(); 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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload