// Getting All Contacts public ArrayList<ProfileDetails> Get_Contacts() { try { profileDetails_list.clear(); // Select All Query String selectQuery = "SELECT * FROM " + TABLE_CONTACTS; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); // looping through all rows and adding to list if (cursor.moveToFirst()) { do { ProfileDetails profileDetails = new ProfileDetails(); profileDetails.setID(Integer.parseInt(cursor.getString(0))); profileDetails.setName(cursor.getString(1)); profileDetails.setPhoneNumber(cursor.getString(2)); profileDetails.setEmail(cursor.getString(3)); // Adding contact to list profileDetails_list.add(profileDetails); } while (cursor.moveToNext()); } // return contact list cursor.close(); db.close(); return profileDetails_list; } catch (Exception e) { // TODO: handle exception Log.e("all_contact", "" + e); } return profileDetails_list; }