// Member Start public Profile getMember(String id) { Profile profile = new Profile(); try { SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.query( DBProfile.TABLE_NAME, null, DBProfile.ID + "=?", new String[] {id}, null, null, null, "1"); cursor.moveToFirst(); if (cursor.getCount() == 1) { profile.ID = cursor.getString(cursor.getColumnIndex(DBProfile.ID)); profile.NAME = cursor.getString(cursor.getColumnIndex(DBProfile.NAME)); profile.RELATIONSHIP = cursor.getString(cursor.getColumnIndex(DBProfile.RELATIONSHIP)); profile.HEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.HEIGHT)); profile.WEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.WEIGHT)); profile.GENDER = cursor.getString(cursor.getColumnIndex(DBProfile.GENDER)); profile.AGE = cursor.getString(cursor.getColumnIndex(DBProfile.AGE)); profile.PHOTO = cursor.getString(cursor.getColumnIndex(DBProfile.PHOTO)); profile.PHONE = cursor.getString(cursor.getColumnIndex(DBProfile.PHONE)); } } catch (Exception e) { L.log(e.toString()); } return profile; }
public ArrayList<Profile> getmembers() { ArrayList<Profile> arrayList = new ArrayList<>(); try { SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query( DBProfile.TABLE_NAME, null, DBProfile.RELATIONSHIP + "!=?", new String[] {"none"}, null, null, null, null); cursor.moveToFirst(); while (!cursor.isAfterLast()) { Profile profile = new Profile(); profile.ID = cursor.getString(cursor.getColumnIndex(DBProfile.ID)); profile.NAME = cursor.getString(cursor.getColumnIndex(DBProfile.NAME)); profile.AGE = cursor.getString(cursor.getColumnIndex(DBProfile.AGE)); profile.HEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.HEIGHT)); profile.WEIGHT = cursor.getString(cursor.getColumnIndex(DBProfile.WEIGHT)); profile.PHOTO = cursor.getString(cursor.getColumnIndex(DBProfile.PHOTO)); profile.RELATIONSHIP = cursor.getString(cursor.getColumnIndex(DBProfile.RELATIONSHIP)); arrayList.add(profile); cursor.moveToNext(); } cursor.close(); db.close(); } catch (Exception e) { L.log(e.toString()); } return arrayList; }