public boolean insert(FamilyProfileClass familyProfile) { this.open(); ContentValues cvInsert = new ContentValues(); cvInsert.put(SQLiteHelper.COL_ICARE_FAMILY_PROFILE_NAME, familyProfile.getFname()); cvInsert.put(SQLiteHelper.COL_ICARE_FAMILY_PROFILE_NUMBER, familyProfile.getFNumber()); cvInsert.put( SQLiteHelper.COL_ICARE_FAMILY_PROFILE_RELATIONSHIP, familyProfile.getFrelationship()); cvInsert.put(SQLiteHelper.COL_ICARE_FAMILY_PROFILE_AGE, familyProfile.getFage()); cvInsert.put(SQLiteHelper.COL_ICARE_FAMILY_PROFILE_BLOOD_GROUP, familyProfile.getFbloodGroup()); cvInsert.put(SQLiteHelper.COL_ICARE_FAMILY_PROFILE_WEIGHT, familyProfile.getFweight()); cvInsert.put(SQLiteHelper.COL_ICARE_FAMILY_PROFILE_HEIGHT, familyProfile.getFheight()); cvInsert.put( SQLiteHelper.COL_ICARE_FAMILY_PROFILE_DATE_OF_BIRTH, familyProfile.getFdateOfBirth()); cvInsert.put( SQLiteHelper.COL_ICARE_FAMILY_PROFILE_SPECIAL_NOTES, familyProfile.getFspecialNotes()); long check = iCareDatabase.insert(SQLiteHelper.TBL_I_CARE_FAMILY_PROFILE, null, cvInsert); this.close(); if (check < 0) return false; else return true; }
// Getting All Doctor public List<FamilyProfileClass> getAllFamilyProfile() { List<FamilyProfileClass> familyProfileClasses = new ArrayList<FamilyProfileClass>(); // Select All Query String selectQuery = "SELECT * FROM " + SQLiteHelper.TBL_I_CARE_FAMILY_PROFILE; iCareDatabase = iCareDbHelper.getWritableDatabase(); Cursor cursor = iCareDatabase.rawQuery(selectQuery, null); // looping through all rows and adding to list if (cursor.moveToFirst()) { do { FamilyProfileClass familyProfileClass = new FamilyProfileClass(); familyProfileClass.setFid(Long.parseLong((cursor.getString(0)))); familyProfileClass.setFname(cursor.getString(1)); familyProfileClass.setFNumber(cursor.getString(2)); familyProfileClass.setFrelationship(cursor.getString(3)); familyProfileClass.setFage(cursor.getString(4)); familyProfileClass.setFbloodGroup(cursor.getString(5)); familyProfileClass.setFheight(cursor.getString(6)); familyProfileClass.setFweight(cursor.getString(7)); familyProfileClass.setFdateOfBirth(cursor.getString(8)); familyProfileClass.setFspecialNotes(cursor.getString(9)); // Adding contact to list familyProfileClasses.add(familyProfileClass); } while (cursor.moveToNext()); } // return contact list return familyProfileClasses; }