// get parents list public ArrayList<Parent> getParentsDetails() { ArrayList<Parent> getparetd = new ArrayList<Parent>(); String selectQuery = null; // if(trigger.equals("all")) // { selectQuery = "SELECT * FROM " + TABLE_PARENTS_DETAILS; // } // else // { // selectQuery = "SELECT * FROM "+TABLE_PARENTS_DETAILS+" where "+PID+" = "+id; // } Parent temp = new Parent(); temp.setParentId("0"); temp.setName("Select existing parent"); getparetd.add(temp); SQLiteDatabase db = this.getReadableDatabase(); try { cursor = (SQLiteCursor) db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { Parent studentList = new Parent(); // StudentList studentList = new StudentList(); studentList.setParentId(cursor.getString(cursor.getColumnIndex(PID))); studentList.setName(cursor.getString(cursor.getColumnIndex(ParentName))); studentList.setEmail(cursor.getString(cursor.getColumnIndex(ParentEmail))); studentList.setAddress(cursor.getString(cursor.getColumnIndex(ParentAddress))); studentList.setContactNumber(cursor.getString(cursor.getColumnIndex(ParentContactInfo))); studentList.setAltContactNumber( cursor.getString(cursor.getColumnIndex(ParentContactInfo_Alt))); studentList.setStudentCount(cursor.getString(cursor.getColumnIndex(Parent_NO_Students))); studentList.setActivestudents( cursor.getString(cursor.getColumnIndex(Parent_No_Of_Active_Student))); studentList.setNotes(cursor.getString(cursor.getColumnIndex(ParentNotes))); studentList.setOutstandingBalance( cursor.getString(cursor.getColumnIndex(Parent_Out_Standing_Balance))); getparetd.add(studentList); // array_studentlist.set(studentList); } while (cursor.moveToNext()); } cursor.getWindow().clear(); cursor.close(); // close inserting data from database db.close(); // return city list return getparetd; } catch (Exception e) { e.printStackTrace(); if (cursor != null) { cursor.getWindow().clear(); cursor.close(); } db.close(); return getparetd; } }